Title: Import database files with VIP-CLI
Author: WordPress VIP Documentation
Published: August 31, 2023
Last modified: October 7, 2025

---

 1. [Databases](https://docs.wpvip.com/databases/)
 2. [Import database files](https://docs.wpvip.com/databases/import/)
 3. Import database files with VIP-CLI

#  Import database files with VIP-CLI

Full or partial SQL database files can be imported to a VIP Platform WordPress environment
using [VIP-CLI](https://docs.wpvip.com/vip-cli/). The `vip import sql` command can
import a SQL database file that is located on a user’s local machine or at a remote
URL.

**Prerequisite**

 * [VIP-CLI is installed](https://docs.wpvip.com/vip-cli/installing-vip-cli/) and
   has been updated to [the most current version](https://www.npmjs.com/package/@automattic/vip/v/latest).
 * A user must have at minimum either an [Org member role](https://docs.wpvip.com/manage-user-access/vip-dashboard/org-roles/)
   or an [App write role](https://docs.wpvip.com/manage-user-access/vip-dashboard/org-roles/)
   for that application.
 * The user’s local machine must have the ability to connect to Amazon Web Services(
   AWS).

**Caution**

`DROP` and `UPDATE` statements in a SQL file for import will replace the existing
data in the corresponding tables of the targeted environment’s database. The previously
existing data in the environment’s database that is overwritten by the imported 
SQL file will be gone.

## Considerations

 * Before attempting to import a file to a VIP Platform environment, use the [`vip import validate-sql` VIP-CLI command](https://docs.wpvip.com/databases/import/validate-sql-file/)
   to verify that the SQL database file is correctly formatted. Resolve any errors
   reported by the `validate-sql` command before importing the SQL file to the VIP
   Platform environment, or before uploading the file to a remote URL for import.
 * It is recommended to perform a local test by [importing the database file to a VIP Local Development Environment](https://docs.wpvip.com/dev-env-add-content/)
   before importing it to a VIP Platform environment. Completing this step helps
   to ensure that importing the prepared database file will provide the expected
   results.
 * If the database for import contains domain name values that do not match the 
   VIP Platform destination site’s domain name, [update the domain names before or during import with a `--search-replace` operation](https://docs.wpvip.com/databases/import/updating-values/).
 * Once a database import to a VIP Platform environment has completed, [site testing is recommended](https://docs.wpvip.com/testing-your-site/)
   to ensure that the results match the expectations of the import.
 * It is possible for the import process to complete successfully, but for other
   conflicting errors to prevent the site from loading properly (e.g. PHP errors
   in a theme). If the results of an import are not as expected after the process
   has completed, the process can be retried.

**Note**

If an environment is in an “[Unlaunched](https://docs.wpvip.com/launch-a-site/unlaunched/)”
state, the site on that environment will go into maintenance mode during a SQL import.
For WordPress multisite environments, all network sites will go into maintenance
mode during a SQL import if the environment is in an “Unlaunched” state. 

The “Launched” or “Unlaunched” state of an environment can be referenced in the 
VIP Dashboard or with [the VIP-CLI command `vip app`](https://docs.wpvip.com/vip-cli/commands/app/).

## Import a local SQL file

#### VIP-CLI command examples

For demonstration purposes, the `<app-name>` value `example-app` and the `<env>`
value `production` are used in the VIP-CLI command examples below. Read more about
[how to target environments in VIP-CLI commands](https://docs.wpvip.com/vip-cli/target-environments/).

A local SQL database file can be imported to a VIP Platform environment with the`
[vip import sql](https://docs.wpvip.com/vip-cli/commands/import/sql/)` VIP-CLI command.

The SQL database file must be available on the local machine under the home directory
of the current user. Identify the absolute or relative path to the SQL database 
file so that it can be passed in the VIP-CLI command.

Example paths for a local SQL file named `file.sql` for a current user named “example-
user”:

 * **macOS:** `/Users/example-user/file.sql`
 * **Windows:** `C:\Users\example-user\file.sql`
 * **Ubuntu:** `/home/example-user/file.sql`

In this example command, a SQL database file named `file.sql` is imported to the
production environment of the “example-app” application:

    ```lang-shell
    vip @example-app.production import sql /Users/example-user/file.sql
    ```

This command example demonstrates a search and replace operation from `http://localhost`
to `https://example.go-vip.net` during the import of a local file:

    ```lang-shell
    vip @example-app.production import sql /Users/example-user/file.sql --search-replace="http://localhost,https://example.go-vip.net"
    ```

## Import a remote SQL file

A SQL database file can be imported from a remote URL (e.g., from a cloud storage
service or backup location) to a VIP Platform environment with the `vip import sql`
VIP-CLI command.

**Note**

For data security, accessing a database file at a remote location should require
some type of authorization method (e.g., pre-signed URL, basic authentication, authorization
token).

Identify the full remote URL of the SQL database file’s location.

 * Example remote URL for an archived database file authorized by a custom header
   and a token: `https://storage.googleapis.com/bucket/backup.sql.gz`
 * Example remote URL formatted with username and password credentials in order 
   for the remote file to be successfully accessed from an environment that has 
   [Basic Authentication](https://docs.wpvip.com/security-controls/basic-authentication/)
   enabled: `https://username:password@example.com/database.sql`

In this example command, a SQL database file is imported from a remote URL to the
production environment of the “example-app” application:

    ```lang-shell
    vip @example-app.production import sql https://example.com/backups/database.sql
    ```

In this example command, a custom authorization header and value is passed with 
the `--header` option in order to access a SQL database file for import from a remote
URL:

    ```lang-shell
    vip @example-app.production import sql https://example.org/file.sql --header="Authorization: Bearer <token-value>"
    ```

In this example command, an MD5 hash is passed with the `--md5` option in order 
to verify the integrity of the contents of a remote SQL database file prior to import.
If the verification fails, the import of the file is canceled.

    ```lang-shell
    vip @example-app.develop import sql https://example.com/file.sql --md5=5d41402abc4b2a76b9719d911017c592
    ```

Last updated: October 07, 2025