The extract command pulls files and database from a WP Staging backup (.wpstg) without needing a running WordPress installation. This is useful for disaster recovery, site inspection, or preparing files for manual import.
What You’ll Get
After extraction, you’ll have:
- All WordPress files (core, themes, plugins, uploads)
- Database SQL file ready for import
- wp-config.php with original settings
Basic Extraction
Extract all files and database to the default output directory (./wpstaging-output):
wpstaging extract backup.wpstgOr use the --from flag:
wpstaging extract --from=backup.wpstgExtract from Remote URL
Extract directly from a remote backup file without downloading it manually first:
wpstaging extract --from=https://example.com/backups/backup.wpstgOr pass the URL directly as an argument:
wpstaging extract https://example.com/backups/backup.wpstgWhat happens:
- Validates the remote file (size and format)
- Displays backup information
- Asks for confirmation before downloading
- Downloads with progress indicator (supports resume for interrupted downloads)
Extract to Custom Directory
Specify where to extract the files:
wpstaging extract --outputdir=/var/www/restored-site backup.wpstgShort form:
wpstaging extract -o /var/www/restored-site backup.wpstgExtract with Database Normalization
WP Staging backups contain placeholders in the database file. Use --normalizedb to replace them with actual values so the SQL file is ready for standard database tools:
wpstaging extract --normalizedb backup.wpstgThis replaces placeholders like:
{WPSTG_TMP_PREFIX}โ temporary table prefix{WPSTG_FINAL_PREFIX}โ final table prefix{WPSTG_NULL}โ SQL NULL{WPSTG_BINARY}โ BINARY data type
Replace Site URL and Database Prefix
Extract while changing the site URL and database prefix for a new environment:
wpstaging extract --normalizedb \
--site-url=https://newdomain.com \
--db-prefix=wp_new_ \
backup.wpstgNote: The --normalizedb flag is required when using --site-url or --db-prefix.
Filter What to Extract
Use --only-* flags to extract specific parts of the backup:
| Flag | Short | Description |
|---|---|---|
--only-wproot | -r | Extract only WordPress root files |
--only-wpcontent | -w | Extract only wp-content directory |
--only-plugins | -i | Extract only plugins |
--only-themes | -t | Extract only themes |
--only-muplugins | -m | Extract only must-use plugins |
--only-uploads | -u | Extract only uploads |
--only-languages | -g | Extract only language files |
--only-dbfile | -b | Extract only database file |
--only-dropins | -e | Extract only drop-in files |
--only-file | -f | Extract only files matching this name |
Example – Extract only the database file:
wpstaging extract --only-dbfile backup.wpstgExample – Extract only plugins:
wpstaging extract -i backup.wpstgSkip Specific Parts
Use --skip-* flags to exclude parts from extraction:
| Flag | Short | Description |
|---|---|---|
--skip-wproot | -R | Skip WordPress root files |
--skip-wpcontent | -W | Skip wp-content directory |
--skip-plugins | -I | Skip plugins |
--skip-themes | -T | Skip themes |
--skip-muplugins | -M | Skip must-use plugins |
--skip-uploads | -U | Skip uploads |
--skip-languages | -G | Skip language files |
--skip-dbfile | -B | Skip database file |
--skip-dropins | -E | Skip drop-in files |
--skip-file | -F | Skip files matching this name |
Example – Extract everything except uploads:
wpstaging extract --skip-uploads backup.wpstgExample – Skip database and uploads:
wpstaging extract -B -U backup.wpstgVerify Extracted Files
Verify the integrity of extracted files by comparing checksums with the backup:
wpstaging extract --verify backup.wpstgOverwrite Behavior
By default, extraction overwrites existing files. To control this:
# Skip overwriting (default is yes)
wpstaging extract --overwrite=no backup.wpstgAll Extract Flags
Flags:
-o, --outputdir string Directory for extracted files (default: ./wpstaging-output)
-n, --normalizedb Normalize database files during extraction
--overwrite string Overwrite existing extraction directory (yes/no) (default "yes")
--site-url string Specify a new WordPress site URL
--verify Verify integrity of extracted files
--db-prefix string Specify a new WordPress database table prefix
--from string Backup file path or remote URL (http/https)Common Use Cases
Disaster Recovery
Extract files from a backup when your WordPress installation is broken:
wpstaging extract --normalizedb --outputdir=/var/www/recovery backup.wpstgExtract Only Database for Manual Import
Get just the database SQL file:
wpstaging extract --only-dbfile --normalizedb backup.wpstgMigrate to New Domain
Extract with new site URL for migration:
wpstaging extract --normalizedb \
--site-url=https://newsite.com \
--outputdir=/var/www/newsite \
backup.wpstgNext Steps
- Restore WordPress from Backup – For full automated restoration
- Inspect Backup Files – View backup contents before extraction
- Create a Local Copy of WordPress Site – Set up a Docker-based local copy