Copy dashboards and questions from one server to another

I’m a BI consultant and normally work on a local server before deploying ‘stuff’ to a customer’s live server.
Is it possible to take parts of a metabase install from one server to another? I’d like to be able to migrate/overwrite data definitions, questions and dashboards without overwriting a customer’s users and other data.

4 Likes

I’ll answer my own question!

First, there’s no ‘proper’ way to do this.
Second, it can be tricky to maintain stuff like the database_id if you try and copy across.
Third, make sure you’re using a real database for your dashboards (I used MySQL).

Start of by making a copy of your customer’s database on your local server.
Have multiple bat files (I’m working in Windows) to start the jar, one for each customer.
Modify the database connection strings to work with your local database once running.

Do your work.

Now to transfer. You can create SQL scripts to move the new rows. I found it easier to use copy and paste from within MySQL Workbench, but that would depend upon you having access to both databases at once. If you’ve modified something rather than changing, you need to update the original row. Don’t delete then insert (I’m not sure if cascading deletes are enabled).

Questions are stored in the report_card table. Nice and easy to move.
Metrics are in metric
Metalayer stuff is in metabase_field. I think this is best modified on the customer’s server, or by just restoring your database over their existing one. There are 1000s of rows and it’s all updates rather than inserts.
Databases are in metabase_database, though I doubt there’s much stuff to modify in there.
Dimensions displayed via foreigh keys are in dimension
Segments are in segment
Dashboards are in report_dashboard and their contents in report_dashboardcard

Hopefully, someone will come along shortly and tell me there’s a MySQL utility that can copy changes across. I know there are similar for MS SQL.

7 Likes

Still talking to myself.
Rather than copy and paste rows, MySQL Workbench allows you to export highlighted rows to csv. Then just a case of importing at the customer database.

2 Likes

I’m listening :slight_smile:

1 Like

This has been the problem since the start for new users.

There should be a function in the UI something like “Export Question as CSV/JSON” and then you can import it in the other metabase instance.

For sure, you’re not alone. What you did should be the best option at the moment.

2 Likes

Something that will make this difficult, even in the future, is the design of the metabase database. There is no unique reference for any entity, just an integer primary key. That makes it impossible to maintain any connection between questions on different servers.
First change to support this needs to be a GUID on every entity. That way, it would be possible to synchronise servers.

3 Likes

As a newbie to Metabase, I've been looking around for a solution to these synchronisation problems, only to find that no official ("proper") solution exists. As I've stated here, Metabase is a great product, but import/export functionality is a requirement for serious development and large-scale deployments.

I'm not sure many new users actually come from a background that would immediately require such functionality. But as the company grows, these features soon become essential. The lack thereof is only feasible if

  1. the database isn't particularly large
  2. there's only a single person working on the Metabase db (no need for git-like branch management, at most one development instance...)
  3. there's only a single production instance running

If these conditions are met (which would be very rare for large companies), then I can see why the current feature set of Metabase would suffice.

Currentlly I am using MS sqlserver, I cannot find it, Plz help me

@jinwang.du Please just make one post: How to backup&restore metabase(questions,dashbords) based on MS Sqlserver