Skip to content

Import a database to a VIP Local Development Environment

Full or partial SQL database files can be imported to a running VIP Local Development Environment. It is recommended to import database files after a VIP Local Development Environment is confirmed to be up and running and has been configured to run with locally cloned application code.

Full SQL database backups for VIP Platform environments can be downloaded on demand from the VIP Dashboard. Backup files include custom tables, and are compatible with the VIP Local Development Environment.

  • The SQL file can include all tables from the database of a WordPress single site or multisite install, or only a specific table—or set of tables—from that database.
  • The database table structure of WordPress multisites differs from the structure of single sites. To work as expected, a SQL file that originated from a multisite install should be imported to a VIP Local Development Environment that was created as a multisite.

Prerequisites

On the user’s local machine:

1. Identify the absolute local path of the SQL file

Example local paths for a 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

2. Validate the SQL file

Verify that the SQL database file is correctly formatted for import with the vip import validate-sql VIP-CLI command. This example command is using the absolute local path from the macOS example in the previous step:

vip import validate-sql/Users/example-user/file.sql

Any errors reported by the validate-sql command must be resolved before importing the SQL file to the local environment.

3. Import the SQL file

Use the vip dev-env import sql command to import a SQL database file to a running local environment.

As part of the import process, the vip dev-env import sql command will automatically:

In this example, the command is importing a SQL database named file.sql to a local environment with an assigned --slug value example-site:

vip dev-env import sql/Users/example-user/file.sql--slug=example-site

During the import process, a --search-replace operation should be run to replace domain values in the SQL file with the domain of the local development environment.

In this example, the value example-site.com is replaced with example-site.vipdev.lndo.site during the import of file.sql to the local environment:

vip dev-env import sql/Users/example-user/file.sql--slug=example-site --search-replace="example-site.com,example-site.vipdev.lndo.site"

SQL database files exported from a multisite install with more than one site on the network should include a --search-replace operation for each network site. In this example command, a --search-replace operation is included for the main site’s domain admin.example-site.com, a network site with the assigned domain example-site.com, and a third network site’s subdirectory domain admin.example-site.com/site-three:

vip dev-env import sql/Users/example-user/file.sql--slug=example-site --search-replace="admin.example-site.com,admin.example-site.vipdev.lndo.site" --search-replace="example-site.com,example-site.vipdev.lndo.site" --search-replace="admin.example-site.com/site-three,site-three.example-site.vipdev.lndo.site"

Using using WP-CLI commands to run additional search-replace operations may be necessary after the import is complete. To accurately run a search-replace operation, the command structure will depend on whether the search-replace is targeting an entire single site, multisite, or specific tables.

Last updated: September 26, 2022