We’re excited to release two new VIP-CLI commands that will help developers export and import a database backup into their local environment in a single step. The new commands will improve developer productivity and reduce errors coming from importing a database backup into a local development environment. This is a large improvement over the current multi-step process
New export command
We are adding the ability to export database contents of a site from VIP-CLI with a single command:
vip export sql @<your-site-id>.<environment-name>
–output=<output-file>
This command automatically detects the latest backup of a site, prepares SQL export, and downloads the file as specified with the –output option. If this option is not specified, it downloads in the user’s current working directory.
$ vip export sql @0000.production --output /home/user/exported.sql.gz
Fetching the latest backup for mytestsite
✓ Latest backup found with timestamp 2023-05-30T08:16:09.000Z
Creating a new export for the backup with timestamp 2023-05-30T08:16:09.000Z
✓ Preparing
✓ Creating backup copy
✓ Requesting download link
✓ Downloading file
File saved to /home/user/exported.sql.gz
Please note that this command does not let you select any specific backup, tables or network sites. We will iteratively add features to it, and for now it can only export the latest backup, all tables and all network sites.
New sync command
To try this feature, ensure that you’re on the latest version of VIP-CLI and simply run the following in your terminal:
vip dev-env sync sql --slug=<your-local-env-slug> @<your-site-id>.<environment-name>
Depending on the size of the database backup, this command may take a bit of time to finish. A successful attempt should look like the following:
$ vip dev-env sync sql --slug=0000-production @0000.production
Fetching the latest backup for mytestsite
✓ Latest backup found with timestamp 2023-05-30T12:43:07.000Z
Creating a new export for the backup with timestamp 2023-05-30T12:43:07.000Z
✓ Preparing
✓ Creating backup copy
✓ Requesting download link
✓ Downloading file - 100.00% (37.01 KB/37.01 KB)
File saved to /tmp/vip-cli-YrjINx/sql-export.sql.gz
Extracting the exported file /tmp/vip-cli-YrjINx/sql-export.sql.gz...
✓ Extracted to /tmp/vip-cli-YrjINx/sql-export.sql
Extracting site urls from the SQL file...
Running the following search-replace operations on the SQL file:
//mytestsite.go-vip.net -> //0000-production.vipdev.lndo.site
✓ Search-replace operation is complete
Importing the SQL file...
Success: The cache was flushed.
Success: Created user 3.
Success: User "vipgo" created.
✓ SQL file imported
Please note that this does not yet have full parity with the feature on the VIP Dashboard. We currently support only importing the latest backup of the entire database, and only single site installations.
To use this feature, please run npm install -g @automattic/vip
to get the latest version of VIP-CLI. Please also verify that your VIP-CLI installation is on version 2.30.0 or above, by running vip --version
from the terminal.
We would love to know what you think. How do you hope to use these new tools? What could be added to improve your experience? Feel free to get in touch!
You must be logged in to post a comment.