{"action":"created","issue":{"url":"https://api.github.com/repos/metabase/metabase/issues/1748","labels_url":"https://api.github.com/repos/metabase/metabase/issues/1748/labels{/name}","comments_url":"https://api.github.com/repos/metabase/metabase/issues/1748/comments","events_url":"https://api.github.com/repos/metabase/metabase/issues/1748/events","html_url":"https://github.com/metabase/metabase/pull/1748","id":127340597,"number":1748,"title":"Commands for dumping MB database & loading dumps :punch:","user":{"login":"camsaul","id":1455846,"avatar_url":"https://avatars.githubusercontent.com/u/1455846?v=3","gravatar_id":"","url":"https://api.github.com/users/camsaul","html_url":"https://github.com/camsaul","followers_url":"https://api.github.com/users/camsaul/followers","following_url":"https://api.github.com/users/camsaul/following{/other_user}","gists_url":"https://api.github.com/users/camsaul/gists{/gist_id}","starred_url":"https://api.github.com/users/camsaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camsaul/subscriptions","organizations_url":"https://api.github.com/users/camsaul/orgs","repos_url":"https://api.github.com/users/camsaul/repos","events_url":"https://api.github.com/users/camsaul/events{/privacy}","received_events_url":"https://api.github.com/users/camsaul/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/metabase/metabase/labels/database%20support","name":"database support","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"camsaul","id":1455846,"avatar_url":"https://avatars.githubusercontent.com/u/1455846?v=3","gravatar_id":"","url":"https://api.github.com/users/camsaul","html_url":"https://github.com/camsaul","followers_url":"https://api.github.com/users/camsaul/followers","following_url":"https://api.github.com/users/camsaul/following{/other_user}","gists_url":"https://api.github.com/users/camsaul/gists{/gist_id}","starred_url":"https://api.github.com/users/camsaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camsaul/subscriptions","organizations_url":"https://api.github.com/users/camsaul/orgs","repos_url":"https://api.github.com/users/camsaul/repos","events_url":"https://api.github.com/users/camsaul/events{/privacy}","received_events_url":"https://api.github.com/users/camsaul/received_events","type":"User","site_admin":false},"milestone":null,"comments":13,"created_at":"2016-01-19T00:57:39Z","updated_at":"2016-01-20T00:09:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/metabase/metabase/pulls/1748","html_url":"https://github.com/metabase/metabase/pull/1748","diff_url":"https://github.com/metabase/metabase/pull/1748.diff","patch_url":"https://github.com/metabase/metabase/pull/1748.patch"},"body":"After considering the options I believe this is the least hacky / sketchy way to get what we want in #1456. We can do a SQL dump of an H2 database, but there are significant dialectal differences between H2 and Postgres/MySQL (not to mention H2's uppercasing of all table and column names). So that route would mean we'd have to translate H2 SQL to PostgreSQL and/or MySQL. \r\n\r\nInstead, we'll just dump the objects into an EDN file and rely on our existing code to insert rows back into the DB. We'll expose 2 new command-line commands, `dump` and `load-dump`:\r\n\r\n###### `dump`\r\n`dump` serializes the contents of the Metabase database to a file.\r\n\r\n```bash\r\n# from leiningen\r\nlein run dump mb-dump.edn\r\n\r\n# from uberjar\r\njava -jar metabase.jar dump mb-dump.edn\r\n```\r\n\r\n###### `load-dump`\r\n\r\n`load-dump` loads the contents of a Metabase DB dump into the DB.\r\n\r\n```bash\r\nMB_DB_TYPE=postgres MB_DB_HOST=localhost MB_DB_PORT=5432 \\\r\n  MB_DB_DBNAME=metabase MB_DB_USER=camsaul lein run load-dump mb-dump.edn\r\n```\r\n\r\nSupplying different DB details for `dump` and `load-dump` can be used to migrate from one underlying DB to another, which would also make this suitable for upgrading from a \"single-player\" instance to a cloud-based one."},"comment":{"url":"https://api.github.com/repos/metabase/metabase/issues/comments/173029970","html_url":"https://github.com/metabase/metabase/pull/1748#issuecomment-173029970","issue_url":"https://api.github.com/repos/metabase/metabase/issues/1748","id":173029970,"user":{"login":"camsaul","id":1455846,"avatar_url":"https://avatars.githubusercontent.com/u/1455846?v=3","gravatar_id":"","url":"https://api.github.com/users/camsaul","html_url":"https://github.com/camsaul","followers_url":"https://api.github.com/users/camsaul/followers","following_url":"https://api.github.com/users/camsaul/following{/other_user}","gists_url":"https://api.github.com/users/camsaul/gists{/gist_id}","starred_url":"https://api.github.com/users/camsaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camsaul/subscriptions","organizations_url":"https://api.github.com/users/camsaul/orgs","repos_url":"https://api.github.com/users/camsaul/repos","events_url":"https://api.github.com/users/camsaul/events{/privacy}","received_events_url":"https://api.github.com/users/camsaul/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T00:09:51Z","updated_at":"2016-01-20T00:09:51Z","body":"I had no trouble connecting to my H2 DB, if you're using the default params it runs H2 in `autoServer` mode which prevents exactly that sort of issue."}}