> [!WARNING]
> **Preview:** Single-hop self-service migration from a customer-hosted Looker instance to Looker (Google Cloud core) is subject to the "Pre-GA Offerings Terms" in the [General Service Terms](https://cloud.google.com/terms/service-terms#1) section of the Service Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).
>
> During the Public Preview, Cloud Customer Care isn't involved in migrations that use the self-service export script. For feedback and questions, send an email to [looker-migrations-eng@google.com](mailto:looker-migrations-eng@google.com).

As an admin of a customer-hosted Looker instance, you can migrate directly to Looker (Google Cloud core) by using a single-hop, self-service export workflow. First, the open-source export script ([`looker_export.py`](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/looker_export.py)) extracts your database, Git model repositories, and Looker encryption keys and encrypts them with your Cloud Key Management Service customer-managed encryption key (CMEK). Next, you upload the encrypted files to Cloud Storage to import them into Looker (Google Cloud core).

If you manage a Looker-hosted instance, see [Self-service migration from Looker (original) to Looker (Google Cloud core)](https://docs.cloud.google.com/looker/docs/looker-core-self-service-migration.md.txt). If you're using the Looker-assisted migration process, see [Exporting data from a customer-hosted Looker instance](https://docs.cloud.google.com/looker/docs/customer-hosted-backup.md.txt).

## Customer-hosted migration options

When you migrate a customer-hosted Looker instance, you can choose between two pathways:

- **Self-service export to Looker (Google Cloud core) (this document):** Recommended if you're migrating directly to Looker (Google Cloud core). This pathway provides a self-service, single-hop export that you manage directly by using provided Python scripts, your own Cloud KMS customer-managed encryption key (CMEK), and your own Cloud Storage bucket.
- **Looker-assisted migration:** Designed for migrating to a Looker-hosted (original) environment, or for organizations that require custom engagement with Google Cloud's Professional Services Organization (PSO) or Cloud Customer Care. This pathway involves support tickets, questionnaire intake, SRE-generated GnuPG (GPG) encryption keys, and manual data handoffs. For instructions, see [Exporting data from a customer-hosted Looker instance](https://docs.cloud.google.com/looker/docs/customer-hosted-backup.md.txt).

## Migration process overview

Migrating a customer-hosted Looker instance to
Looker (Google Cloud core) by using the self-service export workflow involves five
main steps. Before you start step 1, you can optionally run the
`collect_looker_diagnostics.py` script while your Looker
instance is live to check database and directory sizes before cutover.
For more information, see
[Evaluate your instance for migration](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#evaluate-migration).

1. [**Create your Looker (Google Cloud core) instance, CMEK, bucket, and export
   credentials**](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core#create-target-resources): As a one-time setup in Google Cloud, create the target instance for the import, the Cloud KMS key to encrypt your export deliverables, and the Cloud Storage bucket to stage them. Additionally, grant the [required export Identity and Access Management (IAM) permissions](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#required-roles) on the key and bucket to an export service account or user account.
2. [**Prepare your instance for export**](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#prepare-instance-export): Install dependencies on your export host and authenticate with Google Cloud.
3. [**Export and encrypt**](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#export-instance): Stop your customer-hosted instance, run the `looker_export.py` script, and verify the five encrypted deliverables in the `${BACKUP_DIR}/final_artifacts/` directory.
4. [**Upload deliverables to Cloud Storage**](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#upload-deliverables): Upload the five encrypted deliverables to your Cloud Storage migration bucket.
5. [**Import into Looker (Google Cloud core)**](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#upload-and-import): Trigger an import on your target Looker (Google Cloud core) instance by following [Importing your data from a Cloud Storage bucket to a
   Looker (Google Cloud core)
   instance](https://docs.cloud.google.com/looker/docs/looker-core-import-export#importing).

## Choose a database export mode

The single-threaded versus multi-threaded choice applies specifically to database extraction. Both modes stage your Looker file system directories, wrap keys with Cloud KMS and Tink Streaming AEAD, and upload and import deliverables identically.

| Database export mode tab | Database extraction and import | Advantages and trade-offs |
|---|---|---|
| **Single-threaded export** (`mysqldump`) | Uses the standard `mysqldump` utility (included with `mysql-client` or `mariadb-client-core`), packaged in a `.tar.gz` archive with `gzip` or compatible parallel tools such as `pigz` when supported. Restored by using the standard Cloud SQL import path during Looker (Google Cloud core) import. | **Advantage:** Places lower CPU, disk I/O, and connection impact on the source database, and doesn't require extra third-party database packages or separate upstream package downloads. **Trade-off:** Slower single-threaded extraction and restore on large Looker backend databases. |
| **Multi-threaded export** (`mydumper`) | Uses `mydumper` (0.16.0 or later) to extract tables and table chunks in parallel across worker threads, packaged in a `.tar.gz` archive. Automatically restored in parallel by using `myloader` during Looker (Google Cloud core) import. | **Advantage:** Delivers nearly 3x to 10x faster database export performance (plus parallel import restore) when compared to the single-threaded mode, making it well suited for larger databases or tight cutover windows. **Trade-off:** Parallel extraction places higher concurrent CPU, disk I/O, and connection load on the source database. Because `mydumper` speed depends on the configured worker threads (`MYDUMPER_THREADS`, default `4`), start with a smaller thread count such as the default `4` and increase it gradually as database capacity allows. See the [`export-to-core` README](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/README.md) for optimal thread (`MYDUMPER_THREADS`) and chunk-size (`MYDUMPER_CHUNK_ROWS`) configuration. **Caveat:** Requires separately downloading and installing `mydumper` (from the upstream [mydumper releases](https://github.com/mydumper/mydumper/releases) page, subject to its upstream open-source licensing terms) and compression tools such as `zstd`. |

## Before you begin

Before you run `looker_export.py`, verify that your environment meets the
system requirements, confirm your IAM permissions, complete
pre-export preparation, and review what the workflow excludes or overwrites.

### System and encryption requirements

Verify that your customer-hosted Looker instance, database, and
encryption configuration meet the following requirements:

- Your Looker instance must run a [supported Looker release version](https://docs.cloud.google.com/looker/docs/officially-supported-releases.md.txt).
- Your instance must use an external MySQL database (version 8.0.0 or later) or MariaDB database (version 10.4.0 or later).
- If you use AWS KMS, migrate to Looker AES-256 GCM encryption before exporting by following [Changing Looker's encryption keys](https://docs.cloud.google.com/looker/docs/changing-encryption-keys.md.txt).
- Your database character set and collation must be set to `utf8mb4` (recommended) or `utf8`.

### Required IAM permissions

Before you prepare your export host, verify that the Google Cloud user account or
service account JSON key file (`GOOGLE_APPLICATION_CREDENTIALS`) that you use on
the export host has the following IAM roles, or equivalent
custom-role permissions:

| Target Google Cloud resource | Required permissions | Predefined IAM role |
|---|---|---|
| **Cloud KMS CryptoKey** (used in [Export and encrypt](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#export-instance)) | - `cloudkms.cryptoKeyVersions.useToEncrypt` (wraps `LOOKER_MASTER_KEY` and Tink DEK handles) - `cloudkms.cryptoKeyVersions.useToDecrypt` (verifies Tink Envelope AEAD access during pre-flight) | [**Cloud KMS CryptoKey Encrypter/Decrypter**](https://docs.cloud.google.com/iam/docs/roles-permissions/cloudkms.md.txt#cloudkms.cryptoKeyEncrypterDecrypter) (`roles/cloudkms.cryptoKeyEncrypterDecrypter`), or both [`roles/cloudkms.cryptoKeyEncrypter`](https://docs.cloud.google.com/iam/docs/roles-permissions/cloudkms.md.txt#cloudkms.cryptoKeyEncrypter) and [`roles/cloudkms.cryptoKeyDecrypter`](https://docs.cloud.google.com/iam/docs/roles-permissions/cloudkms.md.txt#cloudkms.cryptoKeyDecrypter) |
| **Cloud Storage migration bucket** (used in [Upload deliverables to Cloud Storage](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#upload-deliverables)) | - `storage.objects.create` (uploads the five deliverables in `final_artifacts/`) - `storage.objects.get` and `storage.objects.list` (verifies uploaded files with `gcloud storage ls`) - `storage.objects.delete` (required only if overwriting files in an existing migration folder) | [**Storage Object User**](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectUser) (`roles/storage.objectUser`) or [**Storage Object Admin**](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectAdmin) (`roles/storage.objectAdmin`) |

> [!NOTE]
> **Note:** The account or service account that you use for exporting and uploading can be the same as or different from the account that you use for importing, as long as your export identity has the preceding [required IAM permissions](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#required-roles). For import identity and [Looker service agent](https://docs.cloud.google.com/looker/docs/looker-core-service-account.md.txt) permissions, see [Required permissions for importing from a Cloud Storage bucket](https://docs.cloud.google.com/looker/docs/looker-core-import-export.md.txt#import_required_permissions).

### Pre-export preparation and script options

Before you run `looker_export.py`, complete the following preparation steps. For
configuration options, see the
[`export-to-core` README](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/README.md)
or run `./looker_export.py --help`.

- **Commit all uncommitted LookML code:** Have developers commit and push all uncommitted [Development Mode](https://docs.cloud.google.com/looker/docs/dev-mode-prod-mode.md.txt) changes beforehand. `looker_export.py` doesn't copy individual developer workspaces (`models-user-*`, other than the shared `models-user-looker` directory).
- **Have `LOOKER_MASTER_KEY` ready:** Verify that the person who runs the export knows and has access to the `LOOKER_MASTER_KEY` that was created for your customer-hosted Looker application. `looker_export.py` requires this key to verify the active database Key Encryption Key (KEK) and wrap `LOOKER_MASTER_KEY` with your Cloud KMS CMEK.
- **Optionally disable scheduled plans in the exported artifact:** By default (`DISABLE_SCHEDULED_PLANS=true`), `looker_export.py` disables scheduled plans so that schedules don't run automatically right after you import data into Looker (Google Cloud core). This setting affects **only the exported
  artifact** and doesn't modify your live source database. You can re-enable schedules in Looker (Google Cloud core) whenever you want, or set `DISABLE_SCHEDULED_PLANS=false` before exporting to keep them enabled.
- **Include or exclude Looker Marketplace content:** By default (`EXCLUDE_MARKETPLACE=false`), `looker_export.py` exports installed Looker Marketplace blocks and applications. To exclude Looker Marketplace content instead, set `EXCLUDE_MARKETPLACE=true` before running the export.

### Export scope and overwrite behavior

Review the following export exclusions and import overwrite behavior before you
start the migration:

- **Instance settings (`setting` table) aren't copied:** Because Looker (Google Cloud core) and customer-hosted Looker settings differ, `looker_export.py` doesn't copy general rows from the `setting` table. It copies **only** the `closed_system` and `crypt_canary_gcm` rows. Configure other instance-level settings directly on the target Looker (Google Cloud core) instance after import.
- **OAuth tokens for database credentials aren't copied:** For security reasons, `looker_export.py` doesn't copy OAuth tokens for database credentials from the `oauth_user_state` table. After import, you must reconfigure OAuth database credentials and have users re-authenticate on the target Looker (Google Cloud core) instance.
- **Full export and overwrite import behavior:** Every run of `looker_export.py` starts from the beginning and runs to completion. Exports aren't incremental or resumable. Every import into Looker (Google Cloud core) overwrites any previous data and in-app configuration on the target instance.

## Evaluate your instance for migration (optional)

> [!NOTE]
> **Note:** Running the diagnostic script (`collect_looker_diagnostics.py`) is optional. If you don't need to generate a pre-migration sizing and metadata report, skip this section and proceed directly to [Create your Looker (Google Cloud core) instance, CMEK, bucket, and export credentials](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#create-target-resources).

Before scheduling your cutover window, we recommend running the read-only Python 3 diagnostic script ([`collect_looker_diagnostics.py`](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/collect_looker_diagnostics.py)) on your live customer-hosted Looker server. Because the script uses only the Python standard library and performs strictly read-only checks without downtime, running it ahead of time helps you:

- **Verify local staging disk capacity and target instance sizing:** Measures subdirectory disk usage (`du -hs`) across your Looker application and shared data mounts and sums per-table byte sizes (`data_length + index_length`) so you can confirm at least 1.5x free local staging disk space and right-size your target Looker (Google Cloud core) instance.
- **Decide between `mysqldump` and `mydumper`:** Surfaces large backend tables
  (such as `history`, `event`, or `pdt_event_log`) early so you can decide
  whether you need multi-threaded `mydumper` to fit within your maintenance
  window.

  > [!NOTE]
  > **Note:** If your database size is greater than 75 GB, we recommend choosing `mydumper` for a faster migration.

- **Catch database version, collation, or directory layout issues before cutover:** Confirms MySQL (8.0+) or MariaDB (10.4+) version compatibility, checks per-table character sets and collations (`utf8mb4` or `utf8`), and audits your directory structure (excluding individual `models-user-[0-9]*` developer directories) for unexpected mounts before taking downtime.

### Diagnostic data collected

The diagnostic script gathers the following information:

- **File system structure and sizes:** Top-level subdirectory disk usage (`du -hs`) and directory tree hierarchy across both the Looker application directory and shared data mount.
- **MySQL database metadata:** A single query against `information_schema.tables` that captures the MySQL or MariaDB version, table names, character sets, collations, and table sizes (`data_length + index_length`).

### Security and privacy safeguards

- **Read-only inspection:** Never reads or outputs file contents, SSH private keys (`id_rsa`), certificates, or Git configuration files.
- **Excludes developer workspaces:** Automatically skips individual developer directories (`models-user-[0-9]*`) while preserving shared production directories (`models-user-looker`).
- **Interactive password prompting:** Prompts for database passwords interactively without echoing to the terminal screen and never saves passwords to disk.

### Run the diagnostic script

On your Looker server, clone the [`looker-open-source/customer-scripts`](https://github.com/looker-open-source/customer-scripts) repository. If your directory and database connection variables differ from the defaults, set them. For all variable options, run `./collect_looker_diagnostics.py --help` or see the [`export-to-core` README](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/README.md). Then, run the read-only diagnostic check:

```bash
git clone https://github.com/looker-open-source/customer-scripts.git
cd customer-scripts/export-to-core

export LOOKER_APP_DIR="LOOKER_APP_DIR"
export LOOKER_DATA_DIR="LOOKER_DATA_DIR"
export PRIMARY_DB_HOST="DB_HOST"
export PRIMARY_DB_USER="DB_USER"
export PRIMARY_DB_NAME="DB_NAME"

./collect_looker_diagnostics.py
```

Replace the following values:

- `LOOKER_APP_DIR`: path to your Looker application directory where `looker.jar` is located.
- `LOOKER_DATA_DIR`: path to your Looker shared data directory, if separate from `LOOKER_APP_DIR`, such as in a clustered deployment (default: `/mnt/looker-data`).
- `DB_HOST`, `DB_USER`, and `DB_NAME`: source MySQL or MariaDB hostname or IP address, username, and schema name for your primary Looker MySQL or MariaDB database.

The script writes a diagnostic report to `/tmp/looker_infra_report.txt`
that contains your file system disk usage, directory structure, database size
summary, and per-table breakdown. Expand the following section to view sample
output:

#### Sample diagnostic report output

```
================================================================================
=== LOOKER DIAGNOSTIC REPORT
=== Generated: 2026-11-13T14:30:00Z | Host: looker-app-01
================================================================================

================================================================================
=== FILESYSTEM ANALYSIS: LOOKER_APP_DIR (Application Directory) (/home/looker/looker) ===
================================================================================
--- [1] Subdirectory Disk Usage (du -hs) ---
4.2G    /home/looker/looker
512M    /home/looker/looker/.cache
340M    /home/looker/looker/looker.jar
3.1G    /home/looker/looker/log

--- [2] Directory Structure (excluding models-user-[0-9]*) ---
/home/looker/looker
/home/looker/looker/.cache
/home/looker/looker/log

================================================================================
=== FILESYSTEM ANALYSIS: LOOKER_DATA_DIR (Shared/Data Directory) (/mnt/looker-data) ===
================================================================================
--- [1] Subdirectory Disk Usage (du -hs) ---
1.8G    /mnt/looker-data
620M    /mnt/looker-data/bare_models
16K /mnt/looker-data/deploy_keys
24K /mnt/looker-data/git_hooks
740M    /mnt/looker-data/models
410M    /mnt/looker-data/models-user-looker

--- [2] Directory Structure (excluding models-user-[0-9]*) ---
/mnt/looker-data
/mnt/looker-data/bare_models
/mnt/looker-data/bare_models/ecommerce.git
/mnt/looker-data/deploy_keys
/mnt/looker-data/git_hooks
/mnt/looker-data/models
/mnt/looker-data/models/ecommerce
/mnt/looker-data/models-user-looker

================================================================================
=== LOOKER MYSQL DATABASE DIAGNOSTICS: looker (PRIMARY_DB) ===
================================================================================
>>> STARTING DATABASE COLLECTION FOR DB: looker <<<
---
DATABASE ANALYSIS FOR DB NAME: looker [Label: PRIMARY_DB]
  Host: 192.0.2.10:3306 | User: looker
---
--- [1] Database Size Summary (DB: looker) ---
+---+---+---+---+---+---+---+---+
| mysql_version | table_count | total_data_bytes | total_index_bytes | total_db_bytes | total_db_mib | total_db_gib | est_1_5x_db_staging_gib |
+---+---+---+---+---+---+---+---+
| 8.0.36        |           7 |      24159191040 |        4898947072 |    29058138112 |     27711.99 |        27.06 |                   40.59 |
+---+---+---+---+---+---+---+---+

--- [2] Per-Table Version, Character Set, Collation & Size (DB: looker, Largest First) ---
+---+---+---+---+---+---+
| mysql_version | table_name     | table_charset | table_collation    | total_size  | total_size_mib |
+---+---+---+---+---+---+
| 8.0.36        | history        | utf8mb4       | utf8mb4_general_ci | 19327352832 |       18432.00 |
| 8.0.36        | event          | utf8mb4       | utf8mb4_general_ci |  6442450944 |        6144.00 |
| 8.0.36        | pdt_event_log  | utf8mb4       | utf8mb4_general_ci |  3221225472 |        3072.00 |
| 8.0.36        | dashboard      | utf8mb4       | utf8mb4_general_ci |    48234496 |          46.00 |
| 8.0.36        | look           | utf8mb4       | utf8mb4_general_ci |    16777216 |          16.00 |
| 8.0.36        | setting        | utf8mb4       | utf8mb4_general_ci |       65536 |           0.06 |
| 8.0.36        | encryption_key | utf8mb4       | utf8mb4_general_ci |       32768 |           0.03 |
+---+---+---+---+---+---+

================================================================================
=== DIAGNOSTIC COLLECTION COMPLETE
================================================================================
```

## Create your Looker (Google Cloud core) instance, CMEK, bucket, and export credentials

Create the following Google Cloud resources and export credentials
before preparing your export host:

1. **Create a target Looker (Google Cloud core) instance:**
   Provision the destination instance by following
   [Create a public secure
   connections Looker (Google Cloud core) instance](https://docs.cloud.google.com/looker/docs/looker-core-instance-create). If you need a private
   connections instance instead, create a
   [Private Service Connect](https://docs.cloud.google.com/looker/docs/looker-core-create-psc.md.txt)
   or
   [private services access](https://docs.cloud.google.com/looker/docs/looker-core-create-private-ip.md.txt)
   instance. If you want instance-level CMEK on an **Enterprise**
   or **Embed** instance, you must configure it before creating
   the instance by following
   [Enable CMEK for
   Looker (Google Cloud core)](https://docs.cloud.google.com/looker/docs/looker-core-cmek). You can't enable instance-level CMEK on an
   existing instance.

2. **Create a Cloud KMS CMEK for the migration:**
   Create a key ring and encryption key by following
   [Create a key](https://docs.cloud.google.com/kms/docs/create-key.md.txt). This CMEK is specific to
   the export and import process and is separate from any instance-level CMEK on
   your Looker (Google Cloud core) instance. `looker_export.py`
   uses this key to wrap your encryption keys, and Looker (Google Cloud core)
   uses it to decrypt your deliverables during import.

3. **Create a Cloud Storage bucket:** Create the
   migration bucket that stages your five encrypted deliverables before import
   by following [Create a bucket](https://docs.cloud.google.com/storage/docs/creating-buckets.md.txt).

4. **Set up export credentials and grant IAM
   permissions:** Verify that the Google Cloud user account or service
   account that you use on your export host has the
   [required IAM permissions](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#required-roles) on
   your Cloud KMS CMEK and Cloud Storage migration bucket.

   #### Create a service account and JSON key with Google Cloud CLI (optional)

   If you authenticate on a headless or automated Linux host by using a service account JSON key file, run the following commands from an authenticated workstation to create a dedicated service account, grant the required roles on your Cloud KMS key and Cloud Storage bucket, and generate the `.json` key file:

   ```
   gcloud iam service-accounts create EXPORT_SA_NAME \
       --project=PROJECT_ID \
       --display-name="Looker Core migration export"

   gcloud kms keys add-iam-policy-binding KEY_NAME \
       --project=PROJECT_ID \
       --location=REGION \
       --keyring=KEY_RING \
       --member="serviceAccount:EXPORT_SA_NAME@PROJECT_ID.iam.gserviceaccount.com" \
       --role="roles/cloudkms.cryptoKeyEncrypterDecrypter"

   gcloud storage buckets add-iam-policy-binding gs://YOUR_MIGRATION_BUCKET_NAME \
       --member="serviceAccount:EXPORT_SA_NAME@PROJECT_ID.iam.gserviceaccount.com" \
       --role="roles/storage.objectUser"

   gcloud iam service-accounts keys create PATH_TO_SERVICE_ACCOUNT_KEY.json \
       --iam-account="EXPORT_SA_NAME@PROJECT_ID.iam.gserviceaccount.com"
   ```

   Replace the following values:
   - `EXPORT_SA_NAME`: name for the new export service account.
   - `PROJECT_ID`: your Google Cloud project ID (not the numeric project number).
   - `KEY_NAME`, `REGION`, and `KEY_RING`: CryptoKey name, region, and key ring for your Cloud KMS CMEK.
   - `YOUR_MIGRATION_BUCKET_NAME`: name of your Cloud Storage migration bucket.
   - `PATH_TO_SERVICE_ACCOUNT_KEY`: local path where you want to save the JSON key file.

   Copy `PATH_TO_SERVICE_ACCOUNT_KEY.json` to your export host, set owner-only permissions by using `chmod 600`, and delete the key after your migration completes.

   > [!CAUTION]
   > **Caution:**
   >
   >
   > Service account keys are a security risk if not managed correctly. You are responsible for the
   > security of the private key and for other operations described by
   > [Best practices for managing service account keys](https://docs.cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys.md.txt).
   > If you are prevented from creating a service account key, service account key creation might
   > be disabled for your organization. For more information, see
   > [Managing secure-by-default organization resources](https://docs.cloud.google.com/resource-manager/docs/secure-by-default-organizations).
   >
   >
   > If you acquired the service account key from an external source, you must validate it before use.
   > For more information, see [Security requirements for externally sourced credentials](https://docs.cloud.google.com/docs/authentication/external/externally-sourced-credentials).
   >
   > <br />
   >
## Prepare your instance for export

Complete these one-time setup steps on the Linux host that has access to your
Looker data directory and MySQL or MariaDB database.

### Install dependencies

Select your database extraction mode and install the required system packages.
Required system packages include Python 3.9 or later, Git 2.36.0 or later, the
`mysql` client, `tar`, `gzip`, and gcloud CLI:

### Single-threaded export

Uses `mysqldump` and `gzip`, which are included with standard MySQL or MariaDB
client packages:

```bash
sudo apt-get update
sudo apt-get install -y \
    git \
    python3 \
    python3-pip \
    default-mysql-client \
    tar \
    gzip
```

### Multi-threaded export

Uses `mydumper` (0.16.0 or later, from
[mydumper releases](https://github.com/mydumper/mydumper/releases)) and `zstd`
for parallel extraction:

```bash
sudo apt-get update
sudo apt-get install -y \
    git \
    python3 \
    python3-pip \
    default-mysql-client \
    tar \
    gzip \
    zstd

# Install mydumper (>= 0.16.0) for your distribution, then verify:
mydumper --version
```

Clone the
[`looker-open-source/customer-scripts`](https://github.com/looker-open-source/customer-scripts)
repository and install the required Python libraries. If you already cloned
`customer-scripts` on this host, skip `git clone`, change to
`customer-scripts/export-to-core`, and run `git pull` before installing
`requirements.txt`:

```bash
git clone https://github.com/looker-open-source/customer-scripts.git
cd customer-scripts/export-to-core
pip3 install -r requirements.txt
```

### Authenticate with Google Cloud

[`looker_export.py`](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/looker_export.py)
uses
[Application Default Credentials (ADC)](https://docs.cloud.google.com/docs/authentication/provide-credentials-adc.md.txt)
to call Cloud KMS. Authenticate on the export host with an account or
service account that has the
[required IAM permissions](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#required-roles):

- **Option 1: Interactive user login (gcloud CLI)**

  ```bash
  gcloud auth application-default login
  ```
- **Option 2: Service account JSON key (for headless or automated hosts)**

  ```bash
  chmod 600 "PATH_TO_SERVICE_ACCOUNT_KEY.json"
  export GOOGLE_APPLICATION_CREDENTIALS="PATH_TO_SERVICE_ACCOUNT_KEY.json"
  ```

  Replace `PATH_TO_SERVICE_ACCOUNT_KEY` with the path to your service account JSON key file (excluding the `.json` extension).

## Export and encrypt

[`looker_export.py`](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/looker_export.py)
starts from the beginning and runs to completion on every run without modifying
your live source database or file system:

- **Pre-flight checks:** Verifies CLI tools, versions, Cloud KMS access, `LOOKER_MASTER_KEY` KEK unwrap, and 1.5x free staging disk space.
- **Read-only database extraction:** Runs `mysqldump --single-transaction` or `mydumper --trx-tables --sync-thread-lock-mode=NO_LOCK --skip-ddl-locks` and applies collation, schema, and schedule updates only to local staged files.
- **File system staging:** Copies supported directories (`models`, `models-user-looker`, `models-self-service`, `bare_models`, `remote_dependencies`, `deploy_keys`, `git_hooks`, and `.persistent_store`) from your Looker file system root path.
- **Encryption and manifest:** Wraps `LOOKER_MASTER_KEY` with your Cloud KMS CMEK, encrypts archives with Tink Streaming AEAD (`AES128_CTR_HMAC_SHA256_1MB`), and writes `metadata.json`.

> [!IMPORTANT]
> **Recommended:** Before you run `looker_export.py`, stop your customer-hosted Looker service (on all nodes, if you have a clustered deployment). Stopping the service ensures point-in-time consistency between your database dump and LookML Git repositories.

Stop Looker, change to your `customer-scripts/export-to-core`
directory (if you aren't already in it), set your environment variables, and run
`looker_export.py`. Run `./looker_export.py --help` or see the
[`export-to-core` README](https://github.com/looker-open-source/customer-scripts/blob/main/export-to-core/README.md)
for optional flags. When prompted, enter `MYSQL_PWD` and `LOOKER_MASTER_KEY`.
`looker_export.py` doesn't echo them to the terminal:

```bash
export ON_PREM_LOOKER_DATA_DIR="ON_PREM_LOOKER_DATA_DIR"
export BACKUP_DIR="BACKUP_DIR"
export DB_HOST="DB_HOST"
export DB_USER="DB_USER"
export DB_NAME="DB_NAME"
export KMS_KEY_NAME="projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"
# Uncomment for multi-threaded database export (requires mydumper and zstd):
# export USE_MYDUMPER="true"

./looker_export.py
```

Replace the following values:

- `ON_PREM_LOOKER_DATA_DIR`: path to your Looker file system root directory.
- `BACKUP_DIR`: local output directory (must not overlap with `ON_PREM_LOOKER_DATA_DIR`).
- `DB_HOST`, `DB_USER`, and `DB_NAME`: source MySQL or MariaDB hostname, username, and schema name.
- `PROJECT_ID`, `REGION`, `KEY_RING`, and `KEY_NAME`: Google Cloud project ID (not project number), region, key ring, and CryptoKey name.

### Verify exported deliverables

Confirm that all five encrypted deliverables exist and are non-empty in
`${BACKUP_DIR}/final_artifacts/`, and inspect `${BACKUP_DIR}/looker_export.log`
for warnings:

```bash
ls -lh "${BACKUP_DIR}/final_artifacts/"
```

| Filename | Description |
|---|---|
| `mysql-data` | Tink Streaming AEAD (`AES128_CTR_HMAC_SHA256_1MB`) encrypted `.tar.gz` archive of the `mysqldump` or `mydumper` database export. |
| `mysql-handle` | Cloud KMS envelope-encrypted Tink keyset handle for `mysql-data`. |
| `fs-data` | Tink Streaming AEAD (`AES128_CTR_HMAC_SHA256_1MB`) encrypted `.tar.gz` archive of staged Looker file system directories. |
| `fs-handle` | Cloud KMS envelope-encrypted Tink keyset handle for `fs-data`. |
| `metadata.json` | Migration manifest containing the source Looker version, Cloud KMS CMEK path, encrypted root key, `"source": "LOOKER_ORIGINAL"`, and artifact names. |

## Upload deliverables to Cloud Storage

Authenticate with an identity that has the
[required IAM permissions](https://docs.cloud.google.com/looker/docs/customer-hosted-export-to-core.md.txt#required-roles) on your migration
bucket, and then upload only the five files inside `final_artifacts/`. If you
authenticated with a service account JSON key earlier, replace
`gcloud auth login` with
`gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS"`:

```bash
gcloud auth login

gcloud storage cp "${BACKUP_DIR}/final_artifacts/*" "gs://YOUR_MIGRATION_BUCKET_NAME/MIGRATION_FOLDER/"
gcloud storage ls -l "gs://YOUR_MIGRATION_BUCKET_NAME/MIGRATION_FOLDER/"
```

Replace `YOUR_MIGRATION_BUCKET_NAME` and
`MIGRATION_FOLDER` with your Cloud Storage migration
bucket name and target folder path.

> [!IMPORTANT]
> **Important:** Upload **only** the five files inside `final_artifacts/`. Don't upload `looker_export.py`, `looker_export.log`, or unencrypted staging files.

## Import into Looker (Google Cloud core)

To review the required IAM permissions and import your uploaded
deliverables into your target Looker (Google Cloud core) instance, see
[Importing your data from a Cloud Storage bucket to a
Looker (Google Cloud core)
instance](https://docs.cloud.google.com/looker/docs/looker-core-import-export#importing).

For feedback or questions during the Public Preview, send an email to
[looker-migrations-eng@google.com](mailto:looker-migrations-eng@google.com).

## What's next

- To complete post-import tasks on your target Looker (Google Cloud core) instance, see [Finalize the setup](https://docs.cloud.google.com/looker/docs/looker-core-self-service-migration.md.txt#finalize-setup).