Skip to content

Add content to a VIP Local Development Environment

After a VIP Local Development has been created and is running, SQL files can be imported to the database, media files can be uploaded, and media requests can be redirected to a site’s production environment.

SQL database

  • Full SQL database backups for VIP Platform environments can be downloaded on demand in the VIP Dashboard. Backups include custom tables, and are suitable for use in a local development environment.
  • For environment’s with Database Backup Shipping enabled, shipped backups include custom tables and are suitable for use in a local development environment.

Prepare the SQL file for import

The SQL file for import must be located on the local machine under the home directory of the current user.

For example, the local path for a SQL file named file.sql for a current user named “current-user”:

Mac: /Users/current-user/file.sql
Windows: C:\Users\current-user\file.sql
Ubuntu: /home/current-user/file.sql

The SQL database file can be verified that it is correctly formatted for import with the VIP-CLI command:
vip import validate-sql <path/to/file.sql>

CREATE DATABASE or USE statements in the SQL file will cause validation errors and the import will fail. Remove the lines where those statements appear prior to import.

Import a SQL file to the local environment

Use the import sql command to import a SQL database file. The file can include one or more specific tables, or an entire SQL database for a site.

In this example, the command is importing a SQL database named file.sql, and the command is run from within the same local directory as the file:

vip dev-env import sql file.sql

A --search-replace operation can be run during the import to update domain name values to match the site of the local development environment.

In this example, the value example-site.com will be replaced with example-site.lndo.site during the import of file.sql to the local environment “example-site”:

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

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.

As part of the import process, the import sql command will automatically:

Media files

The VIP Local Development Environment does not have a File System replica, so all images are served locally. If data is imported and URLs search-replaced, these will likely 404 unless the corresponding media is placed in the container filesystem.

To address that we have introduced the concept of Media Redirect Domain. This domain can be set with the --media-redirect-domain parameter to the create subcommand. If set, any requests returning 404 for a resource within uploads directory will be redirected to the media redirect domain – e.g. production site domain.

Images can be uploaded via WordPress functionality, and those should be accessible. The uploads directory is also mapped to the host machine and can be found within a location of the environment.

$ vip dev-env info
  NAME        example-site                                                                           
  LOCATION    /home/wpvip/.local/share/vip/dev-environment/example-site                               
  SERVICES    devtools, nginx, php, database, memcached, phpmyadmin, vip-search, statsd, wordpress 
  NGINX URLS  http://example-site.vipdev.lndo.site/                                                   
  STATUS      DOWN 
$ ls -al /home/wpvip/.local/share/vip/dev-environment/example-site
 total 28
 drwxrwxr-x 5 wpvip wpvip 4096 aug 23 09:01 .
 drwxrwxr-x 7 wpvip wpvip 4096 aug 20 15:55 ..
 drwxrwxr-x 2 wpvip wpvip 4096 aug 23 09:10 config
 -rw-rw-r-- 1 wpvip wpvip 4449 aug 16 09:46 .lando.yml
 drwxr-xr-x 2 wpvip wpvip 4096 jun 18 09:04 log
 drwxr-xr-x 3 wpvip wpvip 4096 aug 16 09:48 uploads

Last updated: April 26, 2022