{"action":"created","comment":{"url":"https://api.github.com/repos/intercity/intercity/pulls/comments/41491465","id":41491465,"diff_hunk":"@@ -0,0 +1,50 @@\n+namespace :intercity do\n+  namespace :backup do\n+    desc \"Intercity | Create a backup of the Intercity system\"\n+    task create: :environment do\n+      configure_cron_mode\n+      Rake::Task[\"intercity:backup:db:create\"].invoke\n+\n+      backup = SystemBackup::Manager.new\n+      backup.pack\n+      backup.cleanup\n+      backup.remove_old\n+    end\n+\n+    desc \"Intercity | Restore a previously created backup\"\n+    task restore: :environment do\n+      configure_cron_mode\n+\n+      backup = SystemBackup::Manager.new\n+      backup.unpack\n+\n+      Rake::Task[\"intercity:backup:db:restore\"].invoke\n+      backup.cleanup\n+    end\n+\n+    namespace :db do\n+      task create: :environment do\n+        $progress.puts \"Dumping database ...\".blue\n+        SystemBackup::Database.new.dump\n+        $progress.puts \"done\".green\n+      end\n+\n+      task restore: :environment do\n+        $progress.puts \"Restoring database ... \".blue\n+        SystemBackup::Database.new.restore\n+        $progress.puts \"done\".green\n+      end\n+    end\n+\n+    def configure_cron_mode\n+      if ENV['CRON']\n+        # We need an object we can say 'puts' and 'print' to; let's use a\n+        # StringIO.\n+        require 'stringio'\n+        $progress = StringIO.new","path":"lib/tasks/intercity/backup.rake","position":44,"original_position":44,"commit_id":"5f044332ec808749b37b45c6fb426526c02976f8","original_commit_id":"5f044332ec808749b37b45c6fb426526c02976f8","user":{"login":"michiels","id":42268,"avatar_url":"https://avatars.githubusercontent.com/u/42268?v=3","gravatar_id":"","url":"https://api.github.com/users/michiels","html_url":"https://github.com/michiels","followers_url":"https://api.github.com/users/michiels/followers","following_url":"https://api.github.com/users/michiels/following{/other_user}","gists_url":"https://api.github.com/users/michiels/gists{/gist_id}","starred_url":"https://api.github.com/users/michiels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michiels/subscriptions","organizations_url":"https://api.github.com/users/michiels/orgs","repos_url":"https://api.github.com/users/michiels/repos","events_url":"https://api.github.com/users/michiels/events{/privacy}","received_events_url":"https://api.github.com/users/michiels/received_events","type":"User","site_admin":false},"body":"Allright!","created_at":"2015-10-08T09:10:26Z","updated_at":"2015-10-08T09:10:26Z","html_url":"https://github.com/intercity/intercity/pull/21#discussion_r41491465","pull_request_url":"https://api.github.com/repos/intercity/intercity/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/intercity/intercity/pulls/comments/41491465"},"html":{"href":"https://github.com/intercity/intercity/pull/21#discussion_r41491465"},"pull_request":{"href":"https://api.github.com/repos/intercity/intercity/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/intercity/intercity/pulls/21","id":46678904,"html_url":"https://github.com/intercity/intercity/pull/21","diff_url":"https://github.com/intercity/intercity/pull/21.diff","patch_url":"https://github.com/intercity/intercity/pull/21.patch","issue_url":"https://api.github.com/repos/intercity/intercity/issues/21","number":21,"state":"open","locked":false,"title":"Add a task to create and restore backups of your Intercity System","user":{"login":"jvanbaarsen","id":1362793,"avatar_url":"https://avatars.githubusercontent.com/u/1362793?v=3","gravatar_id":"","url":"https://api.github.com/users/jvanbaarsen","html_url":"https://github.com/jvanbaarsen","followers_url":"https://api.github.com/users/jvanbaarsen/followers","following_url":"https://api.github.com/users/jvanbaarsen/following{/other_user}","gists_url":"https://api.github.com/users/jvanbaarsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jvanbaarsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvanbaarsen/subscriptions","organizations_url":"https://api.github.com/users/jvanbaarsen/orgs","repos_url":"https://api.github.com/users/jvanbaarsen/repos","events_url":"https://api.github.com/users/jvanbaarsen/events{/privacy}","received_events_url":"https://api.github.com/users/jvanbaarsen/received_events","type":"User","site_admin":false},"body":"This supports making scheduled backups using CRON, also it has a cleanup\r\nmechanism, so your system will not be flooded with old backups.\r\n\r\nMost parts of this code are taken from the GitLab project.\r\n\r\nFixes #20 \r\n\r\n/cc @michiels ","created_at":"2015-10-02T20:31:23Z","updated_at":"2015-10-08T09:10:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ea58e18d039ca420d10e11d132304a6c6e5079a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/intercity/intercity/pulls/21/commits","review_comments_url":"https://api.github.com/repos/intercity/intercity/pulls/21/comments","review_comment_url":"https://api.github.com/repos/intercity/intercity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intercity/intercity/issues/21/comments","statuses_url":"https://api.github.com/repos/intercity/intercity/statuses/5f044332ec808749b37b45c6fb426526c02976f8","head":{"label":"jvanbaarsen:backup-task","ref":"backup-task","sha":"5f044332ec808749b37b45c6fb426526c02976f8","user":{"login":"jvanbaarsen","id":1362793,"avatar_url":"https://avatars.githubusercontent.com/u/1362793?v=3","gravatar_id":"","url":"https://api.github.com/users/jvanbaarsen","html_url":"https://github.com/jvanbaarsen","followers_url":"https://api.github.com/users/jvanbaarsen/followers","following_url":"https://api.github.com/users/jvanbaarsen/following{/other_user}","gists_url":"https://api.github.com/users/jvanbaarsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jvanbaarsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvanbaarsen/subscriptions","organizations_url":"https://api.github.com/users/jvanbaarsen/orgs","repos_url":"https://api.github.com/users/jvanbaarsen/repos","events_url":"https://api.github.com/users/jvanbaarsen/events{/privacy}","received_events_url":"https://api.github.com/users/jvanbaarsen/received_events","type":"User","site_admin":false},"repo":{"id":42707808,"name":"intercity","full_name":"jvanbaarsen/intercity","owner":{"login":"jvanbaarsen","id":1362793,"avatar_url":"https://avatars.githubusercontent.com/u/1362793?v=3","gravatar_id":"","url":"https://api.github.com/users/jvanbaarsen","html_url":"https://github.com/jvanbaarsen","followers_url":"https://api.github.com/users/jvanbaarsen/followers","following_url":"https://api.github.com/users/jvanbaarsen/following{/other_user}","gists_url":"https://api.github.com/users/jvanbaarsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jvanbaarsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvanbaarsen/subscriptions","organizations_url":"https://api.github.com/users/jvanbaarsen/orgs","repos_url":"https://api.github.com/users/jvanbaarsen/repos","events_url":"https://api.github.com/users/jvanbaarsen/events{/privacy}","received_events_url":"https://api.github.com/users/jvanbaarsen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jvanbaarsen/intercity","description":"Simple web control panel for hosting Rails apps.","fork":true,"url":"https://api.github.com/repos/jvanbaarsen/intercity","forks_url":"https://api.github.com/repos/jvanbaarsen/intercity/forks","keys_url":"https://api.github.com/repos/jvanbaarsen/intercity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jvanbaarsen/intercity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jvanbaarsen/intercity/teams","hooks_url":"https://api.github.com/repos/jvanbaarsen/intercity/hooks","issue_events_url":"https://api.github.com/repos/jvanbaarsen/intercity/issues/events{/number}","events_url":"https://api.github.com/repos/jvanbaarsen/intercity/events","assignees_url":"https://api.github.com/repos/jvanbaarsen/intercity/assignees{/user}","branches_url":"https://api.github.com/repos/jvanbaarsen/intercity/branches{/branch}","tags_url":"https://api.github.com/repos/jvanbaarsen/intercity/tags","blobs_url":"https://api.github.com/repos/jvanbaarsen/intercity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jvanbaarsen/intercity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jvanbaarsen/intercity/git/refs{/sha}","trees_url":"https://api.github.com/repos/jvanbaarsen/intercity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jvanbaarsen/intercity/statuses/{sha}","languages_url":"https://api.github.com/repos/jvanbaarsen/intercity/languages","stargazers_url":"https://api.github.com/repos/jvanbaarsen/intercity/stargazers","contributors_url":"https://api.github.com/repos/jvanbaarsen/intercity/contributors","subscribers_url":"https://api.github.com/repos/jvanbaarsen/intercity/subscribers","subscription_url":"https://api.github.com/repos/jvanbaarsen/intercity/subscription","commits_url":"https://api.github.com/repos/jvanbaarsen/intercity/commits{/sha}","git_commits_url":"https://api.github.com/repos/jvanbaarsen/intercity/git/commits{/sha}","comments_url":"https://api.github.com/repos/jvanbaarsen/intercity/comments{/number}","issue_comment_url":"https://api.github.com/repos/jvanbaarsen/intercity/issues/comments{/number}","contents_url":"https://api.github.com/repos/jvanbaarsen/intercity/contents/{+path}","compare_url":"https://api.github.com/repos/jvanbaarsen/intercity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jvanbaarsen/intercity/merges","archive_url":"https://api.github.com/repos/jvanbaarsen/intercity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jvanbaarsen/intercity/downloads","issues_url":"https://api.github.com/repos/jvanbaarsen/intercity/issues{/number}","pulls_url":"https://api.github.com/repos/jvanbaarsen/intercity/pulls{/number}","milestones_url":"https://api.github.com/repos/jvanbaarsen/intercity/milestones{/number}","notifications_url":"https://api.github.com/repos/jvanbaarsen/intercity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jvanbaarsen/intercity/labels{/name}","releases_url":"https://api.github.com/repos/jvanbaarsen/intercity/releases{/id}","created_at":"2015-09-18T07:59:47Z","updated_at":"2015-09-18T07:59:48Z","pushed_at":"2015-10-08T08:07:35Z","git_url":"git://github.com/jvanbaarsen/intercity.git","ssh_url":"git@github.com:jvanbaarsen/intercity.git","clone_url":"https://github.com/jvanbaarsen/intercity.git","svn_url":"https://github.com/jvanbaarsen/intercity","homepage":"https://intercityup.com","size":1029,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"intercity:master","ref":"master","sha":"d8e9687445cee192119fe602ea5aea2f11ed088f","user":{"login":"intercity","id":5263466,"avatar_url":"https://avatars.githubusercontent.com/u/5263466?v=3","gravatar_id":"","url":"https://api.github.com/users/intercity","html_url":"https://github.com/intercity","followers_url":"https://api.github.com/users/intercity/followers","following_url":"https://api.github.com/users/intercity/following{/other_user}","gists_url":"https://api.github.com/users/intercity/gists{/gist_id}","starred_url":"https://api.github.com/users/intercity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intercity/subscriptions","organizations_url":"https://api.github.com/users/intercity/orgs","repos_url":"https://api.github.com/users/intercity/repos","events_url":"https://api.github.com/users/intercity/events{/privacy}","received_events_url":"https://api.github.com/users/intercity/received_events","type":"Organization","site_admin":false},"repo":{"id":39015536,"name":"intercity","full_name":"intercity/intercity","owner":{"login":"intercity","id":5263466,"avatar_url":"https://avatars.githubusercontent.com/u/5263466?v=3","gravatar_id":"","url":"https://api.github.com/users/intercity","html_url":"https://github.com/intercity","followers_url":"https://api.github.com/users/intercity/followers","following_url":"https://api.github.com/users/intercity/following{/other_user}","gists_url":"https://api.github.com/users/intercity/gists{/gist_id}","starred_url":"https://api.github.com/users/intercity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intercity/subscriptions","organizations_url":"https://api.github.com/users/intercity/orgs","repos_url":"https://api.github.com/users/intercity/repos","events_url":"https://api.github.com/users/intercity/events{/privacy}","received_events_url":"https://api.github.com/users/intercity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intercity/intercity","description":"Simple web control panel for hosting Rails apps.","fork":false,"url":"https://api.github.com/repos/intercity/intercity","forks_url":"https://api.github.com/repos/intercity/intercity/forks","keys_url":"https://api.github.com/repos/intercity/intercity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intercity/intercity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intercity/intercity/teams","hooks_url":"https://api.github.com/repos/intercity/intercity/hooks","issue_events_url":"https://api.github.com/repos/intercity/intercity/issues/events{/number}","events_url":"https://api.github.com/repos/intercity/intercity/events","assignees_url":"https://api.github.com/repos/intercity/intercity/assignees{/user}","branches_url":"https://api.github.com/repos/intercity/intercity/branches{/branch}","tags_url":"https://api.github.com/repos/intercity/intercity/tags","blobs_url":"https://api.github.com/repos/intercity/intercity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intercity/intercity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intercity/intercity/git/refs{/sha}","trees_url":"https://api.github.com/repos/intercity/intercity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intercity/intercity/statuses/{sha}","languages_url":"https://api.github.com/repos/intercity/intercity/languages","stargazers_url":"https://api.github.com/repos/intercity/intercity/stargazers","contributors_url":"https://api.github.com/repos/intercity/intercity/contributors","subscribers_url":"https://api.github.com/repos/intercity/intercity/subscribers","subscription_url":"https://api.github.com/repos/intercity/intercity/subscription","commits_url":"https://api.github.com/repos/intercity/intercity/commits{/sha}","git_commits_url":"https://api.github.com/repos/intercity/intercity/git/commits{/sha}","comments_url":"https://api.github.com/repos/intercity/intercity/comments{/number}","issue_comment_url":"https://api.github.com/repos/intercity/intercity/issues/comments{/number}","contents_url":"https://api.github.com/repos/intercity/intercity/contents/{+path}","compare_url":"https://api.github.com/repos/intercity/intercity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intercity/intercity/merges","archive_url":"https://api.github.com/repos/intercity/intercity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intercity/intercity/downloads","issues_url":"https://api.github.com/repos/intercity/intercity/issues{/number}","pulls_url":"https://api.github.com/repos/intercity/intercity/pulls{/number}","milestones_url":"https://api.github.com/repos/intercity/intercity/milestones{/number}","notifications_url":"https://api.github.com/repos/intercity/intercity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intercity/intercity/labels{/name}","releases_url":"https://api.github.com/repos/intercity/intercity/releases{/id}","created_at":"2015-07-13T14:02:19Z","updated_at":"2015-10-06T16:23:51Z","pushed_at":"2015-10-08T08:07:30Z","git_url":"git://github.com/intercity/intercity.git","ssh_url":"git@github.com:intercity/intercity.git","clone_url":"https://github.com/intercity/intercity.git","svn_url":"https://github.com/intercity/intercity","homepage":"https://intercityup.com","size":1248,"stargazers_count":11,"watchers_count":11,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intercity/intercity/pulls/21"},"html":{"href":"https://github.com/intercity/intercity/pull/21"},"issue":{"href":"https://api.github.com/repos/intercity/intercity/issues/21"},"comments":{"href":"https://api.github.com/repos/intercity/intercity/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/intercity/intercity/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/intercity/intercity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intercity/intercity/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/intercity/intercity/statuses/5f044332ec808749b37b45c6fb426526c02976f8"}}}}