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 can either be archived or unarchived when imported.
- 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-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.
Verify that the SQL database file is correctly formatted for import with the vip import validate-sql
VIP-CLI command.
Though an SQL database file can be imported while in an archived format, it must be in an unarchived state in order to run the vip import validate-sql
command against it.
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.
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.
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
.
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
Search and replace domain values
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 @example-app.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 09, 2024