wp-staging-cli is a powerful, high-performance command-line tool designed to process WP Staging backup files from the command line on each major operating system.
With this tool, users can extract, normalize, and inspect the contents of .wpstg
backup files created by the WP Staging plugin. This standalone extractor is programmed in Go, ensuring exceptional speed and efficiency, and operates independently of WordPress.
Note: The cli tool has been renamed from wpstg-extractor to wp-staging-cli. This article refers to the new name, and you will have to adjust the commands.
The command line tool `wp-staging-cli` is part of the WP Staging Developer and Agency plan and can be downloaded from GitHub.
Contents
Key Features
- Extract Backup Files and Database: Access all contents of
.wpstg
backup files. - Database Normalization: Normalize database files within the backup.
- Metadata Dumping: Extract and display metadata from the backup file.
- Index and Header Dumping: Retrieve index and header information from the backup file.
Performance Benchmark
wp-staging-cli is exceptionally fast. For instance, it can extract a 20GB backup in under 36 seconds on an AMD Ryzenโข 7 PRO 7840U with a fast SSD running Ubuntu 22.04.
Installation
Step 1: Download Excutables
- Download the Windows, Linux, and Mac OS executable files from here.
- Extract the zip file and select the appropriate binary for your operating system from the
build
folder. - (Optional) Move the
wp-staging-cli
binary to a directory in yourPATH
for easy access. For example, on Linux:
mv wp-staging-cli /usr/local/bin/
Usage Instructions
To run wp-staging-cli, use the following command:
wp-staging-cli [options] <backupfile.wpstg>
Arguments
<backupfile.wpstg>
: Path to the WP Staging backup file to be processed. This argument is mandatory.
Command options and arguments can be used in any order.
- Options can have a single ‘-‘ or a double ‘–‘ hyphen prefix.
- Options with values can be set with or without ‘=’.
Options
-l, --license=<licensekey> : WP Staging Pro License Key. Required for accessing the backup file.
-o, --outputdir=<directory> : Specify the output directory where processed files will be stored. Default is "./wpstgbackup".
-v, --version : Display wp-staging-cli version number.
-s, --slowdown-cpu : Slow down CPU usage during the iteration process.
-q, --quiet : Suppress the extracted list output.
-n, --normalizedb : Perform database file normalization.
-dp, --dbprefix=<dbprefix> : Specify a new DB prefix to use with `--normalizedb`.
-su, --siteurl=<siteurl> : Specify a new Site URL to use with `--normalizedb`.
-dm, --dump-metadata : Display backup metadata from the backup file.
-di, --dump-index : Display backup index information from the backup file.
-dh, --dump-header : Display backup header information from the backup file.
-or, --only-rootpath : Extract the contents of the root path directory.
-ow, --only-wpcontent : Extract the contents of the 'wp-content' directory.
-op, --only-plugins : Extract the contents of the 'plugins' directory within 'wp-content'.
-ot, --only-themes : Extract the contents of the 'themes' directory within 'wp-content'.
-om, --only-muplugins : Extract the contents of the 'mu-plugins' directory within 'wp-content'.
-ol, --only-languages : Extract the contents of the 'languages' directory within 'wp-content'.
-od, --only-dbfile : Extract the database file only.
-of, --only-file=<string> : Extract the contents of files matching the specified string.
Examples:
wp-staging-cli --license=WPSTGPRO_LICENSE --outputdir=./wpstgbackup backup.wpstg
wp-staging-cli --license=WPSTGPRO_LICENSE --normalizedb --dbprefix=newprefix --siteurl=https://example.com backup.wpstg
With short options:
wp-staging-cli -l WPSTGPRO_LICENSE -o ./wpstgbackup backup.wpstg
wp-staging-cli -l WPSTGPRO_LICENSE -n -dp newprefix -su https://example.com backup.wpstg
Setting the License Key via Environment Variable
The standalone extractor requires an active WP Staging Pro license. (Agency or Developer Plan)
For convenience, you can set the license key using an environment variable:
On Unix-based systems:
export WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEY
At Windows command prompt:
set WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEY
Contributing to wp-staging-cli
We welcome contributions to wp-staging-cli! If you have suggestions, bug reports, or want to contribute code, open an issue on the GitHub repository.
Related Articles
- WordPress Has No Database Table Prefix. How to Fix it.
- How to use WP Staging | Restore. A Standalone WordPress Installer and Backup Restore Tool
- Update WordPress Core Manually if Automatic Update Does Not Work
- How to Disable WordPress Cron Jobs (on a Staging Site)
- How To Resolve The WordPress Failed To Open Stream Error?