{"id":22824307,"url":"https://github.com/arturniklewicz/wordpress-db-sync","last_synced_at":"2026-05-04T10:33:43.842Z","repository":{"id":266096377,"uuid":"897372668","full_name":"ArturNiklewicz/WordPress-DB-Sync","owner":"ArturNiklewicz","description":"Simple but reliable PHP script to safely sync WordPress databases between environments with proper error handling, logging, and backups.","archived":false,"fork":false,"pushed_at":"2024-12-12T13:51:04.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T05:30:01.032Z","etag":null,"topics":["cicd","devops","mariadb","mysql","php","wordpress"],"latest_commit_sha":null,"homepage":"","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/ArturNiklewicz.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":"2024-12-02T14:17:01.000Z","updated_at":"2024-12-12T13:51:09.000Z","dependencies_parsed_at":"2025-02-06T05:28:22.138Z","dependency_job_id":"68fd7d7d-0f2e-44c0-8a5f-57d867d0b4fc","html_url":"https://github.com/ArturNiklewicz/WordPress-DB-Sync","commit_stats":null,"previous_names":["arturniklewicz/wordpress-db-sync"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturNiklewicz%2FWordPress-DB-Sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturNiklewicz%2FWordPress-DB-Sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturNiklewicz%2FWordPress-DB-Sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturNiklewicz%2FWordPress-DB-Sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArturNiklewicz","download_url":"https://codeload.github.com/ArturNiklewicz/WordPress-DB-Sync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246395874,"owners_count":20770276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cicd","devops","mariadb","mysql","php","wordpress"],"created_at":"2024-12-12T17:06:03.729Z","updated_at":"2026-05-04T10:33:42.126Z","avatar_url":"https://github.com/ArturNiklewicz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WordPress Database Sync Tool\nSimple but reliable PHP script to safely sync WordPress databases between environments with proper error handling, logging, and backups.\n\n## TL;DR\n```bash\nEdit config.php with your database credentials\nchmod +x wp-sync.php\n\n# Usage\n./wp-sync.php prod_to_dev  # Sync production to development\n./wp-sync.php dev_to_prod  # Sync development to production\n```\n\n## Flowchart\n```mermaid\nflowchart TD\n    A[Start Sync Process] --\u003e B{Check Current Directory}\n    B --\u003e|Not Found| C[Throw Exception:\u003cbr/\u003eNo WordPress Installation]\n    B --\u003e|Found| D[Detect WordPress Setup]\n    \n    D --\u003e E[Find wp-config.php]\n    E --\u003e F[Parse WordPress Config]\n    F --\u003e G[Load Sync Config]\n    \n    G --\u003e|Config Missing| H[Create Default Config]\n    H --\u003e I[Exit: Edit Config First]\n    \n    G --\u003e|Config Found| J[Validate Environment]\n    J --\u003e K{Check Required Commands}\n    K --\u003e|Missing| L[Throw Exception:\u003cbr/\u003eMissing Requirements]\n    \n    K --\u003e|All Present| M{Parse Sync Direction}\n    M --\u003e|Invalid| N[Throw Exception:\u003cbr/\u003eInvalid Direction]\n    \n    M --\u003e|Valid| O{Target is Production?}\n    O --\u003e|Yes| P[Prompt for Confirmation]\n    P --\u003e|Denied| Q[Cancel Sync]\n    P --\u003e|Confirmed| R[Continue Sync]\n    O --\u003e|No| R\n    \n    R --\u003e S[Create Target DB Backup]\n    S --\u003e T[Export Source Database]\n    T --\u003e U[Import to Target]\n    U --\u003e V[Update Site URLs]\n    \n    V --\u003e W[Cleanup Temp Files]\n    W --\u003e X[Log Success]\n    \n    subgraph \"Safety Checks\"\n        Y[Excluded Tables:\u003cbr/\u003ewp_users\u003cbr/\u003ewp_usermeta]\n        Z[Backup Creation\u003cbr/\u003eBefore Any Changes]\n    end\n    \n    subgraph \"Error Handling\"\n        AA[All Operations\u003cbr/\u003ein Try-Catch Block]\n        BB[Detailed Error Logging]\n        CC[Cleanup on Failure]\n    end\n```\n\n## Features\n- Automatic database backups\n- Safe URL replacement\n- Production sync confirmation\n- Error logging\n- Excluded sensitive tables (users, usermeta)\n- Transaction-safe dumps\n- Shell argument escaping\n\n## Requirements\n- PHP 7.0+\n- MySQL/MariaDB\n- `mysqldump` and `mysql` commands available\n- Write permissions in script directory\n\n## Config Example\n```php\n// config.php\nreturn [\n    'production' =\u003e [\n        'db_host' =\u003e 'production-host',\n        'db_name' =\u003e 'prod_wordpress',\n        'db_user' =\u003e 'prod_user',\n        'db_pass' =\u003e 'prod_pass',\n        'site_url' =\u003e 'https://www.example.com'\n    ],\n    'development' =\u003e [\n        'db_host' =\u003e 'localhost',\n        'db_name' =\u003e 'dev_wordpress',\n        'db_user' =\u003e 'dev_user',\n        'db_pass' =\u003e 'dev_pass',\n        'site_url' =\u003e 'http://localhost:8080'\n    ]\n];\n```\n\n## Security\n- Never commit `config.php`\n- Always use restricted database users\n- Review excluded tables in `$excludedTables`\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturniklewicz%2Fwordpress-db-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturniklewicz%2Fwordpress-db-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturniklewicz%2Fwordpress-db-sync/lists"}