> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Phased Bulk Load Migration

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

A *Phased Bulk Load Migration* involves <InternalLink path="migration-overview">migrating data to CockroachDB</InternalLink> in several phases. Data can be sliced per tenant, per service, per region, or per table to suit the needs of the migration. In this approach, you stop application traffic to the source database *only* for the tables in a particular slice of data. You then migrate that phase of data to the target cluster using <InternalLink path="molt-fetch">MOLT Fetch</InternalLink> during a **downtime window**. Application traffic is then cut over to those target tables after schema finalization and data verification. This process is repeated for each phase of data.

* Data is migrated to the target <InternalLink path="migration-considerations-granularity">in phases</InternalLink>.

* This approach does not utilize <InternalLink path="migration-considerations-replication">continuous replication</InternalLink>.

* <InternalLink path="migration-considerations-rollback">Rollback</InternalLink> is manual. If you wish to roll back before the target has received any writes that are not present on the source database, nothing needs to be done. If you wish to roll back after the target has received writes that are not present on the source database, you must manually replicate these new rows on the source.

This approach is comparable to the <InternalLink path="migration-approach-classic-bulk-load">Classic Bulk Load Migration</InternalLink>, but dividing the data into multiple phases allows each downtime window to be shorter, and it allows each phase of the migration to be less complex. Depending on how you divide the data, it also may allow your downtime windows to affect only a subset of users. For example, dividing the data per region could mean that, when migrating the data from Region A, application usage in Region B may remain unaffected. This approach may increase overall migration complexity: its duration is longer, you will need to do the work of partitioning the data, and you will have a longer period when you run both the source and the target database concurrently.

This approach is best for databases that are too large to migrate all at once, internal tools, dev/staging environments, and production environments that can handle business disruption. It can only be performed if your system can handle downtime for each migration phase, and if your source database can easily be divided into the phases you need.

This page describes an example scenario. While the commands provided can be copy-and-pasted, they may need to be altered or reconsidered to suit the needs of your specific environment.

<img src="https://mintcdn.com/cockroachlabs/mEy4bzaxzRbvNkMw/images/molt/molt_phased_bulk_load_flow.svg?fit=max&auto=format&n=mEy4bzaxzRbvNkMw&q=85&s=1f3c5b889b36fcc6a704b290f652c308" alt="Phased Bulk Load Migration flow" style={{ maxWidth: "100%", display: "block", marginLeft: "auto", marginRight: "auto" }} width="456" height="326" data-path="images/molt/molt_phased_bulk_load_flow.svg" />

## Example scenario

You have a moderately-sized (500GB) database that provides the data store for a web application. You want to migrate the entirety of this database to a new CockroachDB cluster. You will divide this migration into four geographic regions (A, B, C, and D). You schedule a maintenance window for each region over four subsequent evenings, and you announce them to your users (per region) several weeks in advance.

The application runs on a Kubernetes cluster.

**Estimated system downtime:** 4 hours per region.

## Step-by-step walkthroughs

The following walkthroughs demonstrate how to use the MOLT tools to perform this migration for each supported source database:

* <InternalLink path="phased-bulk-load-postgres">Phased Bulk Load Migration from PostgreSQL</InternalLink>
* <InternalLink path="phased-bulk-load-mysql">Phased Bulk Load Migration from MySQL</InternalLink>
* <InternalLink path="phased-bulk-load-oracle">Phased Bulk Load Migration from Oracle</InternalLink>

<Note>
  For CockroachDB-to-CockroachDB migrations, contact your account team for guidance.
</Note>

## See also

* <InternalLink path="migration-overview">Migration Overview</InternalLink>
* <InternalLink path="migration-considerations">Migration Considerations</InternalLink>
* <InternalLink path="migration-approach-classic-bulk-load">Classic Bulk Load Migration</InternalLink>
* <InternalLink path="molt-fetch">MOLT Fetch</InternalLink>
* <InternalLink path="molt-verify">MOLT Verify</InternalLink>
