• Product
  • Pricing
  • Docs
  • Using PostHog
  • Community
  • Company
  • Login
  • Docs

  • Overview
    • Quickstart with PostHog Cloud
    • Overview
      • Android Popular
      • Elixir
      • Flutter
      • Go
      • iOS Popular
      • Java
      • JavaScript Popular
      • Node.js
      • PHP
      • Python
      • React Native Popular
      • Ruby
      • Rust
    • Library comparison
      • Docusaurus v2 3rd party
      • Gatsby 3rd party
      • Google Tag Manager
      • Next.js
      • Nuxt.js
      • Retool
      • RudderStack
      • Segment
      • Sentry
      • Slack
      • Shopify
      • WordPress
    • Ingest live data
    • Ingest historical data
    • Identify users
    • User properties
    • Using a CDP
    • Deploying a reverse proxy
    • Browser extensions
    • Overview
    • Open-Source
      • Disclaimer
      • Deployment
      • Support
    • Enterprise
      • Overview
      • Support
      • Hosting Costs
        • AWS
        • Azure
        • DigitalOcean
        • Google Cloud Platform
        • EU Hosting Companies
        • Other platforms
      • Instance settings
      • Environment variables
      • Securing PostHog
      • Monitoring with Grafana
      • Running behind a proxy
      • Configuring email
      • Helm chart configuration
      • Deploying ClickHouse using Altinity.Cloud
      • Configuring Slack
      • Overview
        • Overview
        • Upgrade notes
        • Overview
        • 0001-events-sample-by
        • 0002_events_sample_by
        • 0003_fill_person_distinct_id2
        • ClickHouse
          • Backup
          • Debug hanging / freezing process
          • Horizontal scaling (Sharding & replication)
          • Kafka Engine
          • Resize disk
          • Restore
          • Vertical scaling
        • Kafka
          • Resize disk
          • Log retention
        • PostgreSQL
          • Resize disk
          • Troubleshooting long-running migrations
        • Plugin server
          • Overview
          • Ingestion lag
          • Jobs not executing
          • Scheduled tasks not executing
        • MinIO
        • Redis
        • Zookeeper
      • Disaster recovery
    • Troubleshooting and FAQs
    • Migrate between PostHog instances
    • Migrate from Amplitude
    • Migrate to PostHog Cloud EU
    • Migrate from a broken self-hosted instance
    • Export your events
    • Overview
    • Tutorial
    • Troubleshooting
    • Developer reference
    • Using the PostHog API
    • Jobs
    • Testing
    • TypeScript types
    • Overview
    • POST-only public endpoints
    • Actions
    • Annotations
    • Cohorts
    • Dashboards
    • Event definitions
    • Events
    • Experiments
    • Feature flags
    • Funnels
    • Groups
    • Groups types
    • Insights
    • Invites
    • Members
    • Persons
    • Plugin configs
    • Plugins
    • Projects
    • Property definitions
    • Session recordings
    • Trends
    • Users
    • Data model
    • Message formatting
    • Microsoft Teams
    • Slack
    • Discord
    • Overview
    • Data model
    • Ingestion pipeline
    • ClickHouse
    • Querying data
    • Overview
    • GDPR guidance
    • HIPAA guidance
    • CCPA guidance
    • SOC 2
    • Data egress & compliance
    • Data deletion
    • Overview
    • Code of conduct
    • Recognizing contributions
    • Badge
  • Using PostHog

  • Table of contents
      • Dashboards
      • Funnels
      • Group Analytics
      • Insights
      • Lifecycle
      • Path analysis
      • Retention
      • Stickiness
      • Trends
      • Heatmaps
      • Session Recording
      • Correlation Analysis
      • Experimentation
      • Feature Flags
      • Actions
      • Annotations
      • Cohorts
      • Data Management
      • Events
      • Persons
      • Sessions
      • UTM segmentation
      • Team collaboration
      • Organizations & projects
      • Settings
      • SSO & SAML
      • Toolbar
      • Notifications & alerts
      • Role based access
    • Overview
      • Amazon Kinesis Import
      • BitBucket Release Tracker
      • Event Replicator
      • GitHub Release Tracker
      • GitHub Star Sync
      • GitLab Release Tracker
      • Heartbeat
      • Ingestion Alert
      • Email Scoring
      • n8n Connector
      • Orbit Connector
      • Redshift Import
      • Rudderstack Import
      • Segment Connector
      • Shopify Connector
      • Stripe Connector
      • Twitter Followers Tracker
      • Zendesk Connector
      • Airbyte Exporter
      • Amazon S3 Export
      • Avo Inspector
      • BigQuery Export
      • Customer.io Connector
      • Databricks Export
      • Engage Connector
      • GCP Pub/Sub Connector
      • Google Cloud Storage Export
      • Hubspot Connector
      • Intercom Connector
      • PagerDuty Connector
      • PostgreSQL Export
      • Redshift Export
      • RudderStack Export
      • Salesforce Connector
      • Sendgrid Connector
      • Sentry Connector
      • Snowflake Export
      • Twilio Connector
      • Variance Connector
      • Pace Integration
      • Zapier Connector
      • Downsampler
      • Event Sequence Timer
      • First Time Event Tracker
      • Property Filter
      • Property Flattener
      • Schema Enforcer
      • Taxonomy Standardizer
      • Unduplicator
      • Advanced GeoIP Enricher
      • Automatic Cohort Creator
      • Currency Normalizer
      • GeoIP Enricher
      • Timestamp Parser
      • URL Normalizer
      • User Agent Populator
      • Pineapple Mode
    • All
    • Actions
    • Apps
    • Cohorts
    • Configuration
    • Data management
    • Dashboards
    • Experimentation
    • Feature flags
    • Funnels
    • Group analytics
    • Heatmaps
    • Insights
    • Path analysis
    • Retention
    • Session recording
    • Toolbar
    • Trends
  • Support
  • Glossary
  • Docs

  • Overview
    • Quickstart with PostHog Cloud
    • Overview
      • Android Popular
      • Elixir
      • Flutter
      • Go
      • iOS Popular
      • Java
      • JavaScript Popular
      • Node.js
      • PHP
      • Python
      • React Native Popular
      • Ruby
      • Rust
    • Library comparison
      • Docusaurus v2 3rd party
      • Gatsby 3rd party
      • Google Tag Manager
      • Next.js
      • Nuxt.js
      • Retool
      • RudderStack
      • Segment
      • Sentry
      • Slack
      • Shopify
      • WordPress
    • Ingest live data
    • Ingest historical data
    • Identify users
    • User properties
    • Using a CDP
    • Deploying a reverse proxy
    • Browser extensions
    • Overview
    • Open-Source
      • Disclaimer
      • Deployment
      • Support
    • Enterprise
      • Overview
      • Support
      • Hosting Costs
        • AWS
        • Azure
        • DigitalOcean
        • Google Cloud Platform
        • EU Hosting Companies
        • Other platforms
      • Instance settings
      • Environment variables
      • Securing PostHog
      • Monitoring with Grafana
      • Running behind a proxy
      • Configuring email
      • Helm chart configuration
      • Deploying ClickHouse using Altinity.Cloud
      • Configuring Slack
      • Overview
        • Overview
        • Upgrade notes
        • Overview
        • 0001-events-sample-by
        • 0002_events_sample_by
        • 0003_fill_person_distinct_id2
        • ClickHouse
          • Backup
          • Debug hanging / freezing process
          • Horizontal scaling (Sharding & replication)
          • Kafka Engine
          • Resize disk
          • Restore
          • Vertical scaling
        • Kafka
          • Resize disk
          • Log retention
        • PostgreSQL
          • Resize disk
          • Troubleshooting long-running migrations
        • Plugin server
          • Overview
          • Ingestion lag
          • Jobs not executing
          • Scheduled tasks not executing
        • MinIO
        • Redis
        • Zookeeper
      • Disaster recovery
    • Troubleshooting and FAQs
    • Migrate between PostHog instances
    • Migrate from Amplitude
    • Migrate to PostHog Cloud EU
    • Migrate from a broken self-hosted instance
    • Export your events
    • Overview
    • Tutorial
    • Troubleshooting
    • Developer reference
    • Using the PostHog API
    • Jobs
    • Testing
    • TypeScript types
    • Overview
    • POST-only public endpoints
    • Actions
    • Annotations
    • Cohorts
    • Dashboards
    • Event definitions
    • Events
    • Experiments
    • Feature flags
    • Funnels
    • Groups
    • Groups types
    • Insights
    • Invites
    • Members
    • Persons
    • Plugin configs
    • Plugins
    • Projects
    • Property definitions
    • Session recordings
    • Trends
    • Users
    • Data model
    • Message formatting
    • Microsoft Teams
    • Slack
    • Discord
    • Overview
    • Data model
    • Ingestion pipeline
    • ClickHouse
    • Querying data
    • Overview
    • GDPR guidance
    • HIPAA guidance
    • CCPA guidance
    • SOC 2
    • Data egress & compliance
    • Data deletion
    • Overview
    • Code of conduct
    • Recognizing contributions
    • Badge
  • Using PostHog

  • Table of contents
      • Dashboards
      • Funnels
      • Group Analytics
      • Insights
      • Lifecycle
      • Path analysis
      • Retention
      • Stickiness
      • Trends
      • Heatmaps
      • Session Recording
      • Correlation Analysis
      • Experimentation
      • Feature Flags
      • Actions
      • Annotations
      • Cohorts
      • Data Management
      • Events
      • Persons
      • Sessions
      • UTM segmentation
      • Team collaboration
      • Organizations & projects
      • Settings
      • SSO & SAML
      • Toolbar
      • Notifications & alerts
      • Role based access
    • Overview
      • Amazon Kinesis Import
      • BitBucket Release Tracker
      • Event Replicator
      • GitHub Release Tracker
      • GitHub Star Sync
      • GitLab Release Tracker
      • Heartbeat
      • Ingestion Alert
      • Email Scoring
      • n8n Connector
      • Orbit Connector
      • Redshift Import
      • Rudderstack Import
      • Segment Connector
      • Shopify Connector
      • Stripe Connector
      • Twitter Followers Tracker
      • Zendesk Connector
      • Airbyte Exporter
      • Amazon S3 Export
      • Avo Inspector
      • BigQuery Export
      • Customer.io Connector
      • Databricks Export
      • Engage Connector
      • GCP Pub/Sub Connector
      • Google Cloud Storage Export
      • Hubspot Connector
      • Intercom Connector
      • PagerDuty Connector
      • PostgreSQL Export
      • Redshift Export
      • RudderStack Export
      • Salesforce Connector
      • Sendgrid Connector
      • Sentry Connector
      • Snowflake Export
      • Twilio Connector
      • Variance Connector
      • Pace Integration
      • Zapier Connector
      • Downsampler
      • Event Sequence Timer
      • First Time Event Tracker
      • Property Filter
      • Property Flattener
      • Schema Enforcer
      • Taxonomy Standardizer
      • Unduplicator
      • Advanced GeoIP Enricher
      • Automatic Cohort Creator
      • Currency Normalizer
      • GeoIP Enricher
      • Timestamp Parser
      • URL Normalizer
      • User Agent Populator
      • Pineapple Mode
    • All
    • Actions
    • Apps
    • Cohorts
    • Configuration
    • Data management
    • Dashboards
    • Experimentation
    • Feature flags
    • Funnels
    • Group analytics
    • Heatmaps
    • Insights
    • Path analysis
    • Retention
    • Session recording
    • Toolbar
    • Trends
  • Support
  • Glossary
  • Docs
  • Migrate & export
  • Migrate from a broken self-hosted instance

Migrating from a broken PostHog self-hosted instance

Last updated: Jan 19, 2023

On this page

  • Requirements
  • Approach
  • Migrate your events
  • Migrate your meta data
  • 1. Create a data dump from your old instance
  • 2. Send events to your new instance
  • Moving a license key

If you're attempting this migration, feel free to ask questions and provide feedback via the PostHog Communty Slack workspace or a GitHub issue.

If your PostHog instance is running we highly recommend the migrating between PostHog instances guide

Requirements

  • Existing PostHog self-hosted instance that you can no longer login too
  • A new PostHog instance

Approach

This migration has two parts:

  1. Migrate your events, this will also create the necessary person, person distinct ID, and related records.
  2. Migrate your meta data (projects, dashboards, insights, actions, cohorts, feature flags, experiments, annotations).
    • Note! It won't move over the following:

Migrate your events

  1. Access your Clickhouse database and export all your events to disk (including uuid, timestamp, distinctid, event, properties, $group0, $group[1-3])
  2. Disable the GeoIP plugin of your new PostHog instance
  3. Write a script to send them as new requests (likely easiest with our node or python library). Here's an example of how we do it with the Replicator app.
  4. Re-enable the GeoIP plugin

Migrate your meta data

To migrate the non-event data (such as user information, feature flags, dashboard configurations, etc), we'll need to create a data dump and load that into the new instance. This non-event data is stored in Postgres.

This is only officially supported for importing events into a new cloud instance of PostHog or an enterprise self-hosted instance using Kubernetes. If you're using a different deployment method, you can still try this approach but we can't guarantee it will work.

  • You should have a clean PostHog cloud or self-hosted PostHog instance up and running. Your new PostHog instance should have no ingested events. We recommend using a fresh and unused installation.
  • Your old and new instances should both be running the exact same version of PostHog (minimum 1.30.0).

1. Create a data dump from your old instance

Please note that this guide assumes your PostHog pods are running in the posthog kubernetes namespace, thus appending -n posthog to kubectl commands. Substitute posthog for the namespace applicable to you, or omit the -n flag if you're using the default namespace.

Access your old PostHog instance and run the following command:

Terminal
# tip: use the flag -U to specify a username if necessary
pg_dump -d posthog -f tmp/export.sql --no-owner --data-only --disable-triggers \
-t posthog_action \
-t posthog_actionstep \
-t posthog_annotation \
-t posthog_cohort \
-t posthog_dashboard \
-t posthog_dashboarditem \
-t posthog_featureflag \
-t posthog_featureflagoverride \
-t posthog_messagingrecord \
-t posthog_organization \
-t posthog_organizationinvite \
-t posthog_organizationmembership \
-t posthog_personalapikey \
-t posthog_plugin \
-t posthog_pluginattachment \
-t posthog_pluginconfig \
-t posthog_pluginstorage \
-t posthog_team \
-t posthog_user \
-t posthog_user_groups \
-t posthog_user_user_permissions

Note: You may see a warning regarding circular dependencies between tables, which shouldn't be an issue as we are using --disable-triggers. If you do run into issues when restoring, try doing a full dump instead of --data-only.

If you do not access your Postgres database via a port-forwarding mechanism to your local machine, you will then need to copy the file from the server to your local system (or the remote server from where you access your new instance). You can do this with scp:

Note: If your old PostHog instance is hosted on Heroku, you should follow this guide to export all of your data, load into a separate database (we recommend a local Postgres instance), and then run the command above.

Terminal
scp <your_username>@<database_hostname>:/tmp/export.sql .

If your old instance was deployed using the Helm chart, you can use:

Terminal
kubectl cp <postgres-pod-name>:/tmp/export.sql ./export.sql # -n posthog

2. Send events to your new instance

You'll need to write a script to process this data and create the following resources on PostHog cloud. The PostHog migrate code which we use to migrate between two cloud instances will likely be useful.

Moving a license key

If you have an existing license key, please email sales@posthog.com to move your license key over.

Questions?

Was this page useful?

Next article

Export events

At PostHog we believe in your right to own your data - this means being able to export the raw events whenever you want. There are several ways to export your events depending on your use case: Method When? Limitations PostHog UI - click "Export" on the events table You need to export a small number of events 3,500 events Events API Great for one-off smaller exports 1 day date range and 3,500 events Data export app You need to export a large number of events No limits If you're looking to…

Read next article

Author

  • Luke Harries
    Luke Harries

Share

Jump to:

  • Requirements
  • Approach
  • Migrate your events
  • Migrate your meta data
  • 1. Create a data dump from your old instance
  • 2. Send events to your new instance
  • Moving a license key
  • Questions?
  • Product

  • Overview
  • Pricing
  • Product analytics
  • Session recording
  • A/B testing
  • Feature flags
  • Apps
  • Customer stories
  • PostHog vs...
  • Docs

  • Quickstart guide
  • Self-hosting
  • Installing PostHog
  • Building an app
  • API
  • Webhooks
  • How PostHog works
  • Data privacy
  • Using PostHog

  • Product manual
  • Apps manuals
  • Tutorials
  • Community

  • Questions?
  • Product roadmap
  • Contributors
  • Partners
  • Newsletter
  • Merch
  • PostHog FM
  • PostHog on GitHub
  • Handbook

  • Getting started
  • Company
  • Strategy
  • How we work
  • Small teams
  • People & Ops
  • Engineering
  • Product
  • Design
  • Marketing
  • Customer success
  • Company

  • About
  • Team
  • Investors
  • Press
  • Blog
  • FAQ
  • Support
  • Careers
© 2023 PostHog, Inc.
  • Code of conduct
  • Privacy policy
  • Terms