Import database files with VIP-CLI
Full or partial SQL database files can be imported to a VIP Platform WordPress environment using VIP-CLI.
Prerequisite
- VIP-CLI is installed and has been updated to the most current version.
- A user must have at minimum either an Org member role or an App write role for that application.
- A SQL database file (e.g. downloaded from Database Backups) must already be located on the local machine under the home directory of the current user. The SQL database file must be decompressed (unarchived) before import.
- The user’s local machine must have the ability to connect to Amazon Web Services (AWS).
Caution
Importing a SQL database to a VIP site will replace data on the site for any SQL tables included in the import file. Pre-existing data that is overwritten by an imported table will be gone.
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
VIP-CLI command examples
For demonstration purposes, the <app-alias>
value mytestsite
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.
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 VIP Platform environment.
Before importing the database file to a VIP environment, it is recommended to perform a test import locally to a VIP Local Development Environment. This step helps to ensure that the prepared database file provides the expected import results.
Note
Before importing the database file to a VIP environment, it is recommended to perform a test import locally to a VIP Local Development Environment. This step helps to ensure that the prepared database file provides the expected import results.
3. Import the SQL file
Import a SQL database to a VIP Platform environment with the vip import sql
VIP-CLI command.
In this example command, a SQL database file named file.sql
is imported to the production environment of the “mytestsite” application:
vip @mytestsite.production import sql /Users/example-user/file.sql
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.
For example, to search for http://localhost
and replace it with https://example.go-vip.net
during import:
vip @mytestsite.production import sql /Users/example-user/file.sql --search-replace="http://localhost,https://example.go-vip.net"
4. Test the results
Once a database import into a VIP environment has completed, site testing is recommended to ensure that the results match the expectations of the import.
Considerations
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 re-tried.
Last updated: September 14, 2023