{"action":"created","comment":{"url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/comments/27482529","id":27482529,"diff_hunk":"@@ -0,0 +1,78 @@\n+<?php\n+\n+namespace Becklyn\\MysqlDumpBundle\\Service;\n+\n+\n+use Doctrine\\DBAL\\Connection;\n+use Symfony\\Component\\Console\\Output\\OutputInterface;\n+use Symfony\\Component\\Filesystem\\Filesystem;\n+use Symfony\\Component\\Process\\Process;\n+use Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException;\n+\n+class MysqlDumpService\n+{\n+\n+    /**\n+     * Performs the actual backup operation for the given database\n+     *\n+     * @param OutputInterface $output\n+     * @param string          $connectionName\n+     * @param Connection      $connection\n+     * @param string          $backupPath\n+     *\n+     * @return bool\n+     */\n+    public function dump (OutputInterface $output, $connectionName, Connection $connection, $backupPath)\n+    {\n+        $fileSystem = new Filesystem();\n+        if (!$fileSystem->exists(dirname($backupPath)))\n+        {\n+            $fileSystem->mkdir(dirname($backupPath));\n+\n+            // Check whether the directory could have been created\n+            if (!$fileSystem->exists(dirname($backupPath)))\n+            {\n+                throw new AccessDeniedException(\"Permission denied. Could not create directory {$backupPath}\");\n+            }\n+        }\n+\n+        $output->write(\"<info>»</info> Dumping <info>{$connection->getDatabase()}</info> (connection: <info>$connectionName</info>)... \");\n+\n+        $dumpCommand = sprintf(\n+            'mysqldump --user=\"%s\" --password=\"%s\" --host=\"%s\" --lock-all-tables \"%s\" | gzip > \"%s\"',\n+            $connection->getUsername(),\n+            $connection->getPassword(),\n+            $connection->getHost(),\n+            $connection->getDatabase(),\n+            $backupPath\n+        );\n+\n+        $process = new Process($dumpCommand);\n+        $process->run();\n+\n+\n+        // We need to determine ourselves whether mysqldump has raised an error\n+        // as its return code is unreliable due to the fact that it's always returning 0\n+        $errorOut = trim($process->getErrorOutput());\n+        $success  = (preg_match('/Got error:.*/', $errorOut) === 0);\n+\n+        if ($success)\n+        {\n+            $output->writeln('<info>done</info>');\n+        }\n+        else\n+        {\n+            $fileSystem->remove($backupPath);\n+            $output->writeln('<error>failed</error>');","path":"Service/MysqlDumpService.php","position":66,"original_position":66,"commit_id":"cb5f5002fb0a507d48f6276140a47a515f5fc199","original_commit_id":"cb5f5002fb0a507d48f6276140a47a515f5fc199","user":{"login":"apfelbox","id":1032411,"avatar_url":"https://avatars.githubusercontent.com/u/1032411?v=3","gravatar_id":"","url":"https://api.github.com/users/apfelbox","html_url":"https://github.com/apfelbox","followers_url":"https://api.github.com/users/apfelbox/followers","following_url":"https://api.github.com/users/apfelbox/following{/other_user}","gists_url":"https://api.github.com/users/apfelbox/gists{/gist_id}","starred_url":"https://api.github.com/users/apfelbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apfelbox/subscriptions","organizations_url":"https://api.github.com/users/apfelbox/orgs","repos_url":"https://api.github.com/users/apfelbox/repos","events_url":"https://api.github.com/users/apfelbox/events{/privacy}","received_events_url":"https://api.github.com/users/apfelbox/received_events","type":"User","site_admin":false},"body":"Throw an exception.","created_at":"2015-03-31T14:16:37Z","updated_at":"2015-03-31T14:16:37Z","html_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1#discussion_r27482529","pull_request_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/comments/27482529"},"html":{"href":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1#discussion_r27482529"},"pull_request":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1","id":32209023,"html_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1","diff_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1.diff","patch_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1.patch","issue_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/1","number":1,"state":"open","locked":false,"title":"Initial MysqlDumpBundle commit","user":{"login":"cH40z-Lord","id":439899,"avatar_url":"https://avatars.githubusercontent.com/u/439899?v=3","gravatar_id":"","url":"https://api.github.com/users/cH40z-Lord","html_url":"https://github.com/cH40z-Lord","followers_url":"https://api.github.com/users/cH40z-Lord/followers","following_url":"https://api.github.com/users/cH40z-Lord/following{/other_user}","gists_url":"https://api.github.com/users/cH40z-Lord/gists{/gist_id}","starred_url":"https://api.github.com/users/cH40z-Lord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cH40z-Lord/subscriptions","organizations_url":"https://api.github.com/users/cH40z-Lord/orgs","repos_url":"https://api.github.com/users/cH40z-Lord/repos","events_url":"https://api.github.com/users/cH40z-Lord/events{/privacy}","received_events_url":"https://api.github.com/users/cH40z-Lord/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-30T09:11:56Z","updated_at":"2015-03-31T14:16:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"358fbe59e96f73e1792395c4933797e7bd40fcaa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/1/comments","statuses_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/statuses/cb5f5002fb0a507d48f6276140a47a515f5fc199","head":{"label":"cH40z-Lord:master","ref":"master","sha":"cb5f5002fb0a507d48f6276140a47a515f5fc199","user":{"login":"cH40z-Lord","id":439899,"avatar_url":"https://avatars.githubusercontent.com/u/439899?v=3","gravatar_id":"","url":"https://api.github.com/users/cH40z-Lord","html_url":"https://github.com/cH40z-Lord","followers_url":"https://api.github.com/users/cH40z-Lord/followers","following_url":"https://api.github.com/users/cH40z-Lord/following{/other_user}","gists_url":"https://api.github.com/users/cH40z-Lord/gists{/gist_id}","starred_url":"https://api.github.com/users/cH40z-Lord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cH40z-Lord/subscriptions","organizations_url":"https://api.github.com/users/cH40z-Lord/orgs","repos_url":"https://api.github.com/users/cH40z-Lord/repos","events_url":"https://api.github.com/users/cH40z-Lord/events{/privacy}","received_events_url":"https://api.github.com/users/cH40z-Lord/received_events","type":"User","site_admin":false},"repo":{"id":33113406,"name":"BecklynMysqlDumpBundle","full_name":"cH40z-Lord/BecklynMysqlDumpBundle","owner":{"login":"cH40z-Lord","id":439899,"avatar_url":"https://avatars.githubusercontent.com/u/439899?v=3","gravatar_id":"","url":"https://api.github.com/users/cH40z-Lord","html_url":"https://github.com/cH40z-Lord","followers_url":"https://api.github.com/users/cH40z-Lord/followers","following_url":"https://api.github.com/users/cH40z-Lord/following{/other_user}","gists_url":"https://api.github.com/users/cH40z-Lord/gists{/gist_id}","starred_url":"https://api.github.com/users/cH40z-Lord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cH40z-Lord/subscriptions","organizations_url":"https://api.github.com/users/cH40z-Lord/orgs","repos_url":"https://api.github.com/users/cH40z-Lord/repos","events_url":"https://api.github.com/users/cH40z-Lord/events{/privacy}","received_events_url":"https://api.github.com/users/cH40z-Lord/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cH40z-Lord/BecklynMysqlDumpBundle","description":"A symfony 2 bundle that uses mysqldump to dump the associated databases.","fork":true,"url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle","forks_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/forks","keys_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/teams","hooks_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/hooks","issue_events_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/issues/events{/number}","events_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/events","assignees_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/assignees{/user}","branches_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/branches{/branch}","tags_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/tags","blobs_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/languages","stargazers_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/stargazers","contributors_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/contributors","subscribers_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/subscribers","subscription_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/subscription","commits_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/contents/{+path}","compare_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/merges","archive_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/downloads","issues_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/issues{/number}","pulls_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/labels{/name}","releases_url":"https://api.github.com/repos/cH40z-Lord/BecklynMysqlDumpBundle/releases{/id}","created_at":"2015-03-30T09:09:59Z","updated_at":"2015-03-31T13:31:44Z","pushed_at":"2015-03-31T13:31:43Z","git_url":"git://github.com/cH40z-Lord/BecklynMysqlDumpBundle.git","ssh_url":"git@github.com:cH40z-Lord/BecklynMysqlDumpBundle.git","clone_url":"https://github.com/cH40z-Lord/BecklynMysqlDumpBundle.git","svn_url":"https://github.com/cH40z-Lord/BecklynMysqlDumpBundle","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Becklyn:master","ref":"master","sha":"775d57f61872820feed003e54198b63ad1df09f8","user":{"login":"Becklyn","id":1044355,"avatar_url":"https://avatars.githubusercontent.com/u/1044355?v=3","gravatar_id":"","url":"https://api.github.com/users/Becklyn","html_url":"https://github.com/Becklyn","followers_url":"https://api.github.com/users/Becklyn/followers","following_url":"https://api.github.com/users/Becklyn/following{/other_user}","gists_url":"https://api.github.com/users/Becklyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Becklyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Becklyn/subscriptions","organizations_url":"https://api.github.com/users/Becklyn/orgs","repos_url":"https://api.github.com/users/Becklyn/repos","events_url":"https://api.github.com/users/Becklyn/events{/privacy}","received_events_url":"https://api.github.com/users/Becklyn/received_events","type":"Organization","site_admin":false},"repo":{"id":32990188,"name":"BecklynMysqlDumpBundle","full_name":"Becklyn/BecklynMysqlDumpBundle","owner":{"login":"Becklyn","id":1044355,"avatar_url":"https://avatars.githubusercontent.com/u/1044355?v=3","gravatar_id":"","url":"https://api.github.com/users/Becklyn","html_url":"https://github.com/Becklyn","followers_url":"https://api.github.com/users/Becklyn/followers","following_url":"https://api.github.com/users/Becklyn/following{/other_user}","gists_url":"https://api.github.com/users/Becklyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Becklyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Becklyn/subscriptions","organizations_url":"https://api.github.com/users/Becklyn/orgs","repos_url":"https://api.github.com/users/Becklyn/repos","events_url":"https://api.github.com/users/Becklyn/events{/privacy}","received_events_url":"https://api.github.com/users/Becklyn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle","description":"A symfony 2 bundle that uses mysqldump to dump the associated databases.","fork":false,"url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle","forks_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/forks","keys_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/teams","hooks_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/hooks","issue_events_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/events{/number}","events_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/events","assignees_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/assignees{/user}","branches_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/branches{/branch}","tags_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/tags","blobs_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/languages","stargazers_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/stargazers","contributors_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/contributors","subscribers_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/subscribers","subscription_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/subscription","commits_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/contents/{+path}","compare_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/merges","archive_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/downloads","issues_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues{/number}","pulls_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/labels{/name}","releases_url":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/releases{/id}","created_at":"2015-03-27T14:17:41Z","updated_at":"2015-03-27T14:17:41Z","pushed_at":"2015-03-31T13:31:43Z","git_url":"git://github.com/Becklyn/BecklynMysqlDumpBundle.git","ssh_url":"git@github.com:Becklyn/BecklynMysqlDumpBundle.git","clone_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle.git","svn_url":"https://github.com/Becklyn/BecklynMysqlDumpBundle","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1"},"html":{"href":"https://github.com/Becklyn/BecklynMysqlDumpBundle/pull/1"},"issue":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/1"},"comments":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Becklyn/BecklynMysqlDumpBundle/statuses/cb5f5002fb0a507d48f6276140a47a515f5fc199"}}}}