Migrating Users to HubSpot Without Downtime: A WordPress Migration Approach

By Alex Denysiuk

7 min read

Migrating users between CRM platforms is rarely just a matter of exporting contacts from one system and importing them into another.

When a WordPress website is already running in production, the process becomes more complicated. Users continue registering, updating their profiles, and interacting with the platform while the migration is happening.

I worked on a CRM migration where HubSpot was introduced as the new CRM. WordPress remained the central platform, and WP-CLI was used to execute and manage the migration.

The main challenge was keeping the existing website operational while moving user data safely and maintaining consistency between systems.

Here is how I approach this kind of migration.

1. Understand the Data Before Writing Code

The first step is understanding what actually needs to be migrated.

Different CRM platforms often represent the same information differently. A field that exists in one system might have a different name, format, or purpose in another.

Before implementing the migration, I would establish a field mapping between the existing data source, WordPress, and HubSpot.

For example:

Source fieldHubSpot propertyNotes
EmailemailPrimary contact identifier
First namefirstnameText
Last namelastnameText
PhonephoneNormalize formatting
CompanycompanyOptional
External IDCustom propertyPreserve original reference

Not every field should necessarily be migrated. Some information might be outdated, duplicated, or no longer relevant.

It is also important to identify relationships between records and understand which system should be considered the source of truth for each field.

Getting this right early prevents a lot of problems later.

2. Use WP-CLI Instead of Browser-Based Scripts

For production migrations, I prefer WP-CLI over scripts triggered through a browser.

There are several reasons:

  • No PHP execution time limitations imposed by normal web requests.
  • Better control over batch processing.
  • Easier logging and error handling.
  • Ability to restart the process without starting from scratch.
  • No dependency on an administrator keeping a browser tab open.

A migration command can also expose useful options such as batch size, dry-run mode, and starting position.

For example:

wp crm-migrate users --batch=500 --dry-run

wp crm-migrate users --batch=500 --from-id=12000

The command names and arguments above illustrate a possible interface rather than an exact record of the original implementation.

The important part is making the migration manageable and repeatable.

3. Make the Migration Idempotent

One of the most important principles in data migration is idempotency.

A migration should be safe to execute more than once.

Imagine that a migration processes 5,000 users and stops unexpectedly. You should be able to restart it without creating duplicate contacts in HubSpot or overwriting information incorrectly.

Email addresses are often useful for identifying contacts, but they should not always be the only identifier.

A better approach is to preserve an external identifier that connects the original record with its corresponding HubSpot contact.

For example, a simplified mapping structure could look like this:

$user_data = [
    'email' => '[email protected]',
    'firstname' => 'John',
    'lastname' => 'Smith',
    'external_id' => '12345',
];

Before creating a new contact, check whether the corresponding record already exists.

The migration should distinguish between:

  • New contacts that need to be created.
  • Existing contacts that need to be updated.
  • Records that should be skipped.
  • Records that require manual review.

This makes recovery much safer.

4. Integrating WordPress with HubSpot

HubSpot becomes the destination for migrated contact information.

The integration layer should be responsible for transforming WordPress or source CRM data into the format expected by HubSpot.

I prefer keeping this logic separate from the WP-CLI command itself.

For example, a simplified architecture could look like this:

WP-CLI Command
      |
      v
Migration Service
      |
      v
Data Mapper
      |
      v
HubSpot API Client
      |
      v
HubSpot CRM

Each component has a specific responsibility:

  • WP-CLI Command: Handles execution arguments and migration progress.
  • Migration Service: Coordinates the migration process.
  • Data Mapper: Converts source fields into HubSpot properties.
  • HubSpot API Client: Handles communication with HubSpot.

This separation makes the implementation easier to maintain and test.

It also means that changes to the HubSpot integration do not require rewriting the entire migration process.

5. Process Users in Batches

Sending thousands of contacts to an external API in a single operation is not a good idea.

Large migrations should be split into smaller batches.

For example:

$batch_size = 500;
$offset = 0;

do {
    $users = get_users([
        'number' => $batch_size,
        'offset' => $offset,
        'fields' => 'all',
    ]);

    if (empty($users)) {
        break;
    }

    foreach ($users as $user) {
        // Transform and migrate the user.
    }

    $offset += $batch_size;

} while (count($users) === $batch_size);

This is a simplified example of batch processing, not a complete migration implementation.

For larger datasets, cursor-based pagination or stable record IDs can be preferable to offsets.

Batch processing helps control memory consumption, API request volume, and execution time.

It also makes it easier to resume the migration from a particular position.

Another important consideration is HubSpot API rate limiting. The integration should handle rate-limit responses and retry temporary failures rather than treating every failed request as a permanent error.

6. Keep the Website Running During Migration

This is where migrating a CRM on a live website becomes particularly interesting.

The website cannot simply stop accepting registrations and profile updates while historical records are being transferred.

Otherwise, changes made during the migration could be lost.

A safer approach is to separate historical data migration from ongoing synchronization.

A possible sequence looks like this:

  1. Prepare the new HubSpot integration.
  2. Make sure new registrations and relevant profile updates are handled by the new integration.
  3. Start migrating historical users in batches.
  4. Track changes that happen while the historical migration is running.
  5. Reconcile records that were updated during the migration.
  6. Verify that the new CRM contains the expected data.
  7. Complete the transition to the new integration.

The exact sequence depends on which system owns each piece of data and how the existing integrations work.

The key principle is that historical migration and live user activity must not overwrite each other.

7. Handle Errors and Keep Migration Logs

External API integrations are not always reliable.

Requests can fail because of temporary network issues, API rate limits, invalid data, or unexpected responses.

A migration should never silently ignore these failures.

I would track at least:

  • Successfully migrated records.
  • Updated existing contacts.
  • Skipped records.
  • Failed API requests.
  • Validation errors.
  • Records requiring manual review.

A simplified logging example:

WP_CLI::log(
    sprintf(
        'User %d: %s',
        $user_id,
        $status
    )
);

For a production migration, structured logs containing record identifiers, timestamps, and error details are much more useful than generic success or failure messages.

It is also important to avoid logging sensitive personal information unnecessarily.

Temporary API failures should be retried with appropriate backoff. Invalid records should be recorded separately so they can be investigated without blocking the entire migration.

8. Validate the Migration Before Switching Completely

A successful migration command does not necessarily mean that all data was transferred correctly.

Validation should happen throughout the process, not only at the end.

I would compare:

  • Total number of source records.
  • Number of successfully migrated contacts.
  • Number of skipped and failed records.
  • A sample of individual records and their properties.
  • External identifiers between the two systems.

For example, if the source contains 10,000 eligible contacts, the final migration report should explain what happened to all 10,000 records.

The numbers do not necessarily need to match exactly if some records are intentionally excluded, but every difference should be explainable.

9. Have a Rollback Strategy

Even with careful preparation, migrations can expose unexpected problems.

Before making changes, keep a backup of the relevant data and preserve the existing integration code.

A rollback strategy should define:

  • How to restore the previous integration.
  • How to identify records created or modified during migration.
  • How to handle updates made after the transition.
  • How to prevent duplicate synchronization when switching back.

One important detail: rolling back an integration does not automatically reverse changes already made in HubSpot.

Those changes need to be considered separately.

Final Thoughts

Migrating users between CRM platforms on a live WordPress website requires more than a working API connection.

The most important parts are understanding the data, making the migration repeatable, processing records safely, handling API failures, and maintaining consistency while the website continues operating.

Using WP-CLI provides a practical way to manage the process without relying on browser requests or interrupting normal website activity.

And perhaps the biggest lesson is this: a migration is not complete when the script finishes. It is complete when you can verify that the data is correct and the new integration works reliably in production.

Written by

Alex Denysiuk

Senior PHP engineer: WordPress, Laravel, React. 9+ years of building plugins, themes, APIs and a production LMS with 400K+ users. Open to full-time roles and contract work.