{"id":17931839,"url":"https://github.com/mbovel/wp-backup-restore-command","last_synced_at":"2026-04-18T04:02:15.241Z","repository":{"id":85879626,"uuid":"83609416","full_name":"mbovel/wp-backup-restore-command","owner":"mbovel","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-11T10:14:30.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T12:24:44.230Z","etag":null,"topics":["backup","prototype","restore","wordpress","wp-cli-package"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbovel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2017-03-01T22:45:56.000Z","updated_at":"2020-03-22T04:43:12.000Z","dependencies_parsed_at":"2023-03-13T07:13:45.400Z","dependency_job_id":null,"html_url":"https://github.com/mbovel/wp-backup-restore-command","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbovel/wp-backup-restore-command","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovel%2Fwp-backup-restore-command","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovel%2Fwp-backup-restore-command/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovel%2Fwp-backup-restore-command/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovel%2Fwp-backup-restore-command/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbovel","download_url":"https://codeload.github.com/mbovel/wp-backup-restore-command/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovel%2Fwp-backup-restore-command/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["backup","prototype","restore","wordpress","wp-cli-package"],"created_at":"2024-10-28T21:24:07.948Z","updated_at":"2026-04-18T04:02:15.222Z","avatar_url":"https://github.com/mbovel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP-CLI Backup/Restore command proposition\n\nThis is a prototype to test some ideas I emitted in [this discussion](https://github.com/wp-cli/ideas/issues/5). To fix english and code mistakes, please feel free to pull request here. For further ideas and comments, please participe directly to the original discussion: \u003chttps://github.com/wp-cli/ideas/issues/5\u003e.\n\nFor an example of how this command could be used, see [example-wp-setup](https://github.com/mbovel/example-wp-setup).\n\n## Backup/Restore core\n\nThe command `wp backup core \u003e core.json` generates something like that:\n\n\t{\n\t    \"version\": \"4.7.1\",\n\t    \"locales\": [],\n\t    \"path\": \"\"\n\t}\n\nwhere:\n\n- `version` holds the WordPress version,\n- `locales` holds a list of installed core translations (restoring those is not implemented yet),\n- `path` holds the path to the WordPress installation (not sure if useful as the same can be set in a `wp-cli.yml` file).\n\n`wp restore core \u003c core.json` restores core files.\n\n## Backup/Restore database\n\nThe command `wp backup db \u003e db.sql` generates an SQL dump of the database, with installation URLs replaced by constants. For example, all instances of the home url are replaced by `HOME_URL`, instances of the uploads directory url by `UPLOADS_URL` and so on:\n\n\t...\n\tINSERT INTO `wp_options` VALUES\n    (1,'siteurl','SITE_URL','yes'),\n    (2,'home','HOME_URL','yes'),\n    (3,'blogname','WP CLI Site','yes'),\n\t...\n\n`wp restore db \u003c db.sql` restores core files.\n\n## Backup/Restore plugins\n\nThe command `wp backup plugins \u003e plugins.json` generates something like that:\n\n\t{\n\t    \"akismet\\/akismet.php\": {\n\t        \"name\": \"Akismet\",\n\t        \"path\": \"akismet\\/akismet.php\",\n\t        \"version\": \"3.1\",\n\t        \"active\": true,\n\t        \"source\": \"wordpress.org\",\n\t        \"handle\": \"akismet\"\n\t    }\n\t}\n\nRight now, the command can only backup and restore plugins from the official wordpress.org repository. The idea however would be to handle more sources: git and svn repositories, S3, etc. The exact content of the JSON object for each plugin would depend on its source.\n\n## Implementation concerns\n\n### Why JSON?\n\n1. These files do not need to be edited by humans.\n2. That increases potentiel ease of integration with other tools: no need for a YAML parser.\n\n### Database dump replacements\n\nIt is useful to replace URLs in the backup because:\n\n1. That makes it easy to restore the backup in a different setup where URLs are different.\n2. That makes the dump more git-friendly: no differences if you backup from different environments.\n\nThese replacements are now implemented with naive text replacement on the SQL dump through `str_replace`. In real life, `wp search-replace` functionalities should be reused as much as possible for a safer and cleaner dump. It was not used in this prototype because it does not have an easy way to handle multiple replacements yet.\n\nPlease note the importance of having different constants for home, installation, uploads, plugins and content URLs, and the order in which the replacements are made. This is mandatory to support non-standard setups (see [example-wp-setup](https://github.com/mbovel/example-wp-setup) for example).\n\n### Plugin name\n\nThe namespace WP-CLI uses to refer to plugins and themes seems to be inconsistent. For uninstalling and other commands, the file name (see `WP_CLI\\Utils\\get_plugin_name`) is used:\n\n\twp plugin uninstall hello\n\nWherever for installing, the handle from wordpress.org is used:\n\n\twp plugin install hello-dolly\n\nAs in this example, these two strings do not always match.\n\nIn this prototype, both the full path of the plugin's main file and the worpress.org handle are saved in the backup JSON file.\n\nWhen restoring plugins, each one is reinstalled unless there is an already installed plugin that match all of the following characteristics: path, handle, source, version *and* wherever it should be activated or not (and a files checksum could be added).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbovel%2Fwp-backup-restore-command","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbovel%2Fwp-backup-restore-command","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbovel%2Fwp-backup-restore-command/lists"}