WP Staging Restore Tool – Filter Configuration

The standalone restore tool supports customizing restore behavior through a JSON configuration file. This provides filter-based customization similar to the WordPress plugin, but without requiring WordPress to be running.

Note: If no wpstg-restore-config.json file exists, the restore tool runs with its normal default behavior.

How It Works

  1. Place a file named wpstg-restore-config.json in the same directory as wpstg-restore.php.
  2. The tool reads the config on startup and applies the filter values during restore.
  3. If no config file exists, the tool behaves as usual using all defaults.

Config File Format

{
  "version": 1,
  "filters": {
    "filter.name": "value"
  }
}
  • version: Schema version. Must be 1.
  • filters: Object mapping filter names to their values.

See wpstg-restore-config.example.json for a complete example with all filters set to defaults.

Available Filters

Boolean Filters

These filters accept true or false.

Filter NameDefaultDescription
wpstg.backup.restore.keepExistingPluginsfalseWhen true, existing plugins are not deleted before restoring. Backup plugins are merged into the existing directory.
wpstg.backup.restore.keepExistingThemesfalseWhen true, existing themes are not deleted before restoring.
wpstg.backup.restore.keepExistingMuPluginsfalseWhen true, existing mu-plugins are not deleted before restoring.
wpstg.backup.restore.keepExistingMediafalseWhen true, existing uploads and media files are not deleted before restoring.
wpstg.backup.restore.keepExistingOtherFilesfalseWhen true, other files in wp-content are not deleted before restoring.
wpstg.backup.restore.innodbStrictModeOfffalseWhen true, disables InnoDB strict mode during database import. This is useful when restoring from a server with different InnoDB settings.

Array Filters

These filters accept an array of strings.

Filter NameDefaultDescription
wpstg.backup.restore.exclude_backup_parts[]Parts to skip entirely during restore. Valid values: plugins, themes, uploads, muplugins, wpcontent, wpstgdb, lang, dropins, wproot.
wpstg.backup.restore.exclude_paths[]Directory paths to exclude during file restore. A trailing / is added automatically, so "starter-templates" matches paths containing starter-templates/ but not starter-templates-pro/. Example: ["starter-templates", "elementor"].
wpstg.backup.restore.exclude.tables[]Database table names to skip during database restore. Example: ["wp_comments", "wp_commentmeta"].
wpstg.database.import.excludedQueries[]SQL query patterns to skip during database import. Queries containing any of these strings will be excluded.

Important: For exclude_paths, a trailing slash is added automatically. This helps avoid accidental partial matches.

Example Configurations

Restore but keep existing plugins and themes

{
  "version": 1,
  "filters": {
    "wpstg.backup.restore.keepExistingPlugins": true,
    "wpstg.backup.restore.keepExistingThemes": true
  }
}

Restore only the database

Use this configuration to skip all file-related backup parts.

{
  "version": 1,
  "filters": {
    "wpstg.backup.restore.exclude_backup_parts": [
      "plugins",
      "themes",
      "uploads",
      "muplugins",
      "wpcontent",
      "dropins",
      "wproot",
      "lang"
    ]
  }
}

Exclude specific tables from database restore

{
  "version": 1,
  "filters": {
    "wpstg.backup.restore.exclude.tables": [
      "wp_comments",
      "wp_commentmeta",
      "wp_wc_orders"
    ]
  }
}

Exclude specific plugins and themes from file restore

{
  "version": 1,
  "filters": {
    "wpstg.backup.restore.exclude_paths": [
      "starter-templates",
      "elementor",
      "themes/flavor"
    ]
  }
}

Restore files only

Use this configuration to skip the database restore.

{
  "version": 1,
  "filters": {
    "wpstg.backup.restore.exclude_backup_parts": ["wpstgdb"]
  }
}

How Filters Are Consumed

  1. Directly by Restorer: The keepExisting*, exclude_backup_parts, and exclude_paths filters are read directly by the restore tool’s Restorer class to control which parts are restored, whether existing files are deleted first, and which file paths to skip during restore.
  2. Via ApplyFiltersTrait: The database-related filters such as exclude.tables, excludedQueries, and innodbStrictModeOff are consumed by the bundled DatabaseImporter class through the ApplyFiltersTrait. This trait checks FilterConfig as a fallback when WordPress hooks are not available.

Validation and Logging

  • Unknown filter names are logged as warnings and ignored.
  • Type mismatches, for example setting a boolean filter to an array, are logged as warnings and skipped.
  • All active filters are logged at restore startup for debugging.
  • Malformed JSON produces a warning, and the restore continues with default behavior.
  • Unsupported config versions produce a warning, and all filters are skipped.

Debugging tip: If a filter does not seem to apply, first check the restore logs for warnings about unknown filter names, invalid types, malformed JSON, or an unsupported config version.

Security

  • Only whitelisted filter names are accepted.
  • Only primitive types such as bool and string, plus arrays of strings, are supported.
  • No callable or code execution is possible through the config file.

Updated on April 10, 2026

Rene Hermenau

Author: Rene Hermenau

About the author: René Hermenau is the founder of WP STAGING. He works on WordPress backups, staging, migrations, database handling, and safe deployment workflows.