If you're attempting this migration, feel free to ask questions and provide feedback via the PostHog Communty Slack workspace or a GitHub issue. You can also raise a support ticket in the app.
Requirements
- Existing PostHog instance that you can login to (Self-hosted versions need a minimum version of
1.30.0
, if you version is lower you'll need to upgrade to this version first) - A new PostHog instance
Approach
This migration has two parts:
- Migrate your events, this will also create the necessary person, person distinct ID, and related records.
- Migrate your meta data (projects, dashboards, insights, actions, cohorts, feature flags, experiments, annotations).
- Note! It won't move over the following:
- Project API Key. You'll need to replace the API key in your code with the new API key.
- "created by" information. Every object will appear as if it was created by you.
- "created at" information. Every object will appear as if it was created on the time you ran this script.
- Note! It won't move over the following:
Migrate your events
To migrate your events, we'll be using the PostHog Replicator app:
- Disable the GeoIP plugin of your new PostHog instance
- Log in to your old PostHog instance
- Click 'Apps' on the left-hand tool bar
- Search for 'Replicator'
- If self-hosted, select the app, press 'Install' (or make sure it's the latest version)
- For the configuration details using the following:
Host
: the hostname of your new PostHog instance e.g.app.posthog.com
if you are using US cloud,eu.posthog.com
if you were are EU cloud, or the domain you'll be sending events to if you are self-hostingProject API Key
: the API key for the new project that you want to send events to - found in the project settings page.
- After clicking save and activating it (toggle on the left side), the Replicator will start to run. Any events added to your old instance will be replicated in your new instance. It can take a little while (15-20 minutes) for the first events to show up.
- Once the Replicator is activated, go back to the configuration menu and click the gear next to "Export historical events" under "Jobs." On the calendar, select a start and end date, then click "Run job now." This will begin the process of historical events being import (and might take a while). You can see the progress in logs or by clicking the "App metrics" button (graph) and going to the "Historical exports" tab.
- To track progress of the export you can click the graph icon next to the Replicator app and then click on the "Historical Exports" tab
- Re-enable the GeoIP plugin of your new PostHog instance
Migrate your meta data
Follow the instructions on the PostHog migrate metadata repo:
- Clone the repo and cd into itTerminalgit clone https://github.com/PostHog/posthog-migrate-metacd posthog-migrate-meta
- Install the dependencies by running
yarn
- Run the scriptTerminalts-node index.ts --source [posthog instance you want to migrate from] --sourcekey [personal api key for that instance] --destination [posthog instance you want to migrate to.] --destinationkey [personal api key for destination instance]
For more information on the options see the repo's readme