{"id":36971423,"url":"https://github.com/makers99/wp-cli-db-export-clean","last_synced_at":"2026-01-13T21:53:40.407Z","repository":{"id":46179995,"uuid":"360825672","full_name":"makers99/wp-cli-db-export-clean","owner":"makers99","description":"Create minimal database dumps without customer data for external/freelancers and CI/CD.","archived":false,"fork":false,"pushed_at":"2025-11-10T11:10:39.000Z","size":87,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-11-10T13:08:39.797Z","etag":null,"topics":["ci","ci-cd","continuous-integration","database","devops","dump","mysql","php","privacy","security","woocommerce","wordpress","wp-cli","wp-cli-command","wp-cli-package"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makers99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-04-23T09:06:56.000Z","updated_at":"2025-11-10T11:10:42.000Z","dependencies_parsed_at":"2022-08-30T03:01:58.043Z","dependency_job_id":null,"html_url":"https://github.com/makers99/wp-cli-db-export-clean","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/makers99/wp-cli-db-export-clean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makers99%2Fwp-cli-db-export-clean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makers99%2Fwp-cli-db-export-clean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makers99%2Fwp-cli-db-export-clean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makers99%2Fwp-cli-db-export-clean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makers99","download_url":"https://codeload.github.com/makers99/wp-cli-db-export-clean/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makers99%2Fwp-cli-db-export-clean/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28401380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","ci-cd","continuous-integration","database","devops","dump","mysql","php","privacy","security","woocommerce","wordpress","wp-cli","wp-cli-command","wp-cli-package"],"created_at":"2026-01-13T21:53:39.617Z","updated_at":"2026-01-13T21:53:40.398Z","avatar_url":"https://github.com/makers99.png","language":"PHP","readme":"# makers99/wp-cli-db-export-clean\n\nAdds the WP-CLI command `wp db export-clean` to create a MySQL database dump\nwithout sensitive data related to customers and optionally API secrets/credentials,\nwhile retaining all administrative users and their related data.\n\nRevisions are excluded as well to minimize the dump file size.\n\nQuick links: [Usage](#usage) | [Integration](#integration) | [Installation](#installation) | [Support](#support)\n\n## Usage\n\n```\nwp db export-clean [\u003cfilepath\u003e] [--remove-keys]\n```\n\n### Arguments\n\nThe command accepts the result filename as argument. If omitted, it defaults to\n`./clean.sql`.\n\n### Options\n\n|Option|Description|Default|\n|------|-----------|-------|\n|`--remove-keys`|Additionally remove options containing license keys and API credentials during dump.|`false`|\n\n\n### Examples\n\n- Create clean database dump in `./clean.sql`:\n    ```console\n    $ wp db export-clean\n    ```\n\n- Create clean database dump in the user's home directory:\n    ```console\n    $ wp db export-clean ~/clean.sql\n    ```\n\n- Exclude plugin license keys and API keys in the clean database dump – useful when working with plugin vendor support or unknown freelancers:\n    ```console\n    $ wp db export-clean --remove-keys\n    ```\n\n\n\n\n## Integration\n\n### Supported plugins\n\n- WordPress Core (keeping only posts and comments from retained users, omitting revisions, transients and caches)\n- [WooCommerce](https://wordpress.org/plugins/woocommerce/) (only orders from retained users, omitting scheduled actions and sessions)\n- [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) (only subscriptions from retained users)\n- [Gravityforms](https://www.gravityforms.com/) (omitting revisions, entries, and statistics)\n- [wp-lister-amazon](https://www.wplab.com/plugins/wp-lister-for-amazon/), [wp-lister-ebay](https://www.wplab.com/plugins/wp-lister-for-ebay/) (omitting feeds, jobs, logs)\n- [Yoast wordpress-seo](https://wordpress.org/plugins/wordpress-seo/) (omitting index tracking, migrations, links)\n\n### Placing the filter hooks\n\n`wp db export-clean` runs directly after WordPress is loaded (like `wp db export`), which means that only wp-config.php and plugins are loaded but WordPress is not bootstrapped with init hooks.  You can place your hooks into a must-use plugin; for example:\n\n`wp-content/mu-plugins/wp-cli-db-export-clean.php`:\n```php\n\u003c?php\n\n/*\n  Plugin Name: wp db export-clean Customizations\n  Version: 1.0.0\n  Description: Includes test users in the clean database dump.\n*/\n\nadd_filter('wp-db-export-clean/allowed-emails', function ($allowed_emails) {\n  return array_unique(array_merge($allowed_emails, [\n    'test@example.com',\n  ]));\n});\n```\n\n### Including more users in the database export\n\n`wp db export-clean` only includes users having the role Administrator by default. Use the filter hook `'wp-db-export-clean/allowed-emails'` to include more users in the database dump:\n\n```php\n/**\n * Customizes list of email addresses to retain in clean database dump.\n *\n * @return array\n *   An array whose items are email addresses to keep.\n */\nadd_filter('wp-db-export-clean/allowed-emails', function ($allowed_emails) {\n  global $wpdb;\n  $users = $wpdb-\u003eget_col(\n    $wpdb-\u003eprepare(\"SELECT u.user_email FROM {$wpdb-\u003eprefix}users u WHERE u.user_email LIKE '%%%s'\", '@example.com')\n  );\n  return array_unique(array_merge($allowed_emails, $users));\n});\n```\nIn addition, you can include users by ID:\n```php\n/**\n * Customizes list of user IDs to retain in clean database dump.\n *\n * @return array\n *   An array whose items are user IDs to keep.\n */\nadd_filter('wp-db-export-clean/allowed-user-ids', function ($allowedUserIds) {\n  $allowedUserIds[] = 123;\n  $allowedUserIds[] = 456;\n  return array_unique($allowedUserIds);\n});\n```\n\n### Including more WooCommerce orders or subscriptions in the database export\n\n```php\n/**\n * Customizes list of shop order/subscription IDs to retain in clean database dump.\n *\n * @return array\n *   An array whose items are shop_order IDs to keep.\n */\nadd_filter('wp-db-export-clean/allowed-order-ids', function ($allowedOrderIds) {\n  $allowedOrderIds[] = 123456;\n  return array_unique($allowedOrderIds);\n});\n```\n\n### Excluding more/custom data in the database export\n\nImplement the following filter hook to customize the where conditions for all tables.\n\n```php\n/**\n * Customizes select query conditions for each table in clean database dump.\n *\n * @return array\n *   An array whose keys are table names and whose values are SQL WHERE clause conditions.\n */\nadd_filter('wp-db-export-clean/table-wheres', function ($tableWheres) {\n  global $wpdb;\n\n  $tableWheres = array_merge($tableWheres, [\n    \"{$wpdb-\u003eprefix}my_log\" =\u003e '1 = 0',\n    \"{$wpdb-\u003eprefix}my_userdata\" =\u003e \"user_id IN ({$allowedUserIds})\",\n  ]);\n  return $tableWheres;\n});\n```\n\n### Excluded licenses and API keys\n\nWhen passing the `--remove-keys` option, the following plugins are currently supported:\n\n- WooCommerce (PayPal)\n- [WooCommerce PayPal Plus](https://www.angelleye.com/product/woocommerce-paypal-plus-plugin/)\n- [WooCommerce PayPal Express Checkout](https://woocommerce.com/document/paypal-express-checkout/) (woocommerce-gateway-paypal-express-checkout)\n- [wp-lister-amazon](https://www.wplab.com/plugins/wp-lister-for-amazon/)\n- [wp-lister-ebay](https://www.wplab.com/plugins/wp-lister-for-ebay/)\n- [Gravityforms](https://www.gravityforms.com/)\n- [WooThemes](https://www.woothemes-plugins.com/) (wp-all-import, wp-all-export)\n- [Optimus](https://optimus.io/)\n- [Elementor](https://elementor.com/)\n- [SearchWP](https://searchwp.com/)\n- [Gravityforms Zero Spam](https://www.gravityforms.com/add-ons/zero-spam/)\n- [WooCommerce Amazon Payments](https://wordpress.org/plugins/woocommerce-gateway-amazon-payments-advanced/)\n\n\n## Installation\n\n### Install as package\n\n1. To install the latest version of this package for the current user:\n    ```sh\n    wp package install makers99/wp-cli-db-export-clean\n    ```\n\n### Install as Git submodule\n\n1. Add the package as submodule.\n    ```sh\n    git submodule add --name wp-cli-db-export-clean git@github.com:makers99/wp-cli-db-export-clean.git .wp-cli/packages/db-export-clean\n    ```\n\n2. Register the command for early WP-CLI bootstrap.\n    ```sh\n    echo -e \"require:\\n  - .wp-cli/packages/db-export-clean/package.php\" \u003e\u003e wp-cli.yml\n    ```\n    Or manually:\n    ```sh\n    vi wp-cli.yml\n    ```\n    ```yaml\n    require:\n      - .wp-cli/packages/db-export-clean/plugin.php\n    ```\n\n### Install with Composer\n\n1. Install the package with Composer.\n    ```sh\n    composer config repositories.wp-cli-db-export-clean git https://github.com/makers99/wp-cli-db-export-clean.git\n    composer require makers99/wp-cli-db-export-clean:dev-master\n    ```\n    Note: Do not use `--dev` to install as `require-dev`, because export-clean\n    is typically used in production.\n\n2. Register the command for early WP-CLI bootstrap.\n    ```sh\n    echo -e \"require:\\n  - vendor/makers99/wp-cli-db-export-clean/package.php\" \u003e\u003e wp-cli.yml\n    ```\n    Or manually:\n    ```sh\n    vi wp-cli.yml\n    ```\n    ```yaml\n    require:\n      - vendor/makers99/wp-cli-db-export-clean/package.php\n    ```\n\n\n## Support\n\n### MySQL errors during export\n\nAdd to `wp-cli.yml` in your site root folder:\n```yml\ndb export:\n  max-allowed-packet: 1G\n```\n\n\n## Come create with us!\n\nOriginally authored by [Bogdan Arizancu](https://github.com/bogdanarizancu) and [Daniel Kudwien](https://github.com/sun).\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://makers99.com/#jobs\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/makers99/makers99/main/assets/makers99-github-banner.png\" width=\"100%\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakers99%2Fwp-cli-db-export-clean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakers99%2Fwp-cli-db-export-clean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakers99%2Fwp-cli-db-export-clean/lists"}