https://github.com/posthog/posthog-migrate-meta
Migrate metadata from one organization to another
https://github.com/posthog/posthog-migrate-meta
Last synced: 9 months ago
JSON representation
Migrate metadata from one organization to another
- Host: GitHub
- URL: https://github.com/posthog/posthog-migrate-meta
- Owner: PostHog
- Created: 2022-11-03T16:42:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T17:10:30.000Z (over 1 year ago)
- Last Synced: 2025-04-02T22:43:28.492Z (9 months ago)
- Language: TypeScript
- Size: 46.9 KB
- Stars: 4
- Watchers: 7
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PostHog migrate metadata
This tool helps move your metadata (ie everything but events) from one PostHog instance to another, for example from your self hosted PostHog instance to PostHog cloud.
Usage
```bash
yarn
ts-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]
```
Options
- `--source` URL of the PostHog instance you want to move from, without a trailling `/`. Example: `https://posthog.example.com`. Defaults to `https://app.posthog.com`
- `--sourcekey` Person API key, created on the source instance. See [these intructions](https://posthog.com/docs/api#how-to-obtain-a-personal-api-key) on how to generate the personal api key
- `--destination` URL of the PostHog instance you want to move to, without a trailling `/`. Example: `https://posthog.example.com`. Defaults to `https://app.posthog.com`
- `--destinationkey` Person API key, created on the destination instance. See [these intructions](https://posthog.com/docs/api#how-to-obtain-a-personal-api-key) on how to generate the personal api key
- `--projects` A list of project ids to move over. Will default to moving _all_ projects. Example: `--projects 1 2`
- `--projectmap` If you've already created a project on the new instance and you want to move existing projects there, you can map them. Example: `--projectmap 1:81250` (source:destination)
## How to use
1. Set up an organization on the new PostHog instance
1. Move events over see https://posthog.com/docs/migrate.
1. Use this script as outlined above.
## Using this tool to copy across the same instance or organisation
You can also use this tool to copy settings across the same instance and organisation. Just use the same settings for both source and destination. The new project will have `(copy)` added to the name.
## How it works
It'll migrate the following objects
- Projects (you can pick projects using the `--projects` option)
- 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.
- Events/Persons. You'll need to use the [Events migration tool](https://github.com/PostHog/posthog-migration-tools) afterwards.
- "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.
You can safely run this script multiple times using the same parameters as it'll write the objects it's already moved over to state.json.