Skip to content

Import database files with VIP-CLI

Full or partial SQL database files can be imported to a VIP Platform WordPress environment using 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

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 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 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.
  • Once a database import to a VIP Platform environment has completed, site testing is recommended 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” 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.

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.

A local SQL database file can be imported to a VIP Platform environment with the vip 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:

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:

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 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:

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:

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.

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

Last updated: October 07, 2025

Relevant to

  • WordPress