{"id":23893970,"url":"https://github.com/manoj-lk-code/php-script-for-wordpress-backup","last_synced_at":"2025-08-31T08:33:33.252Z","repository":{"id":186209349,"uuid":"609148803","full_name":"manoj-lk-code/php-script-for-wordpress-backup","owner":"manoj-lk-code","description":"Allows you to create backup for WordPress site even if you don't have access to control panel","archived":false,"fork":false,"pushed_at":"2023-09-25T04:41:03.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-12T01:05:12.010Z","etag":null,"topics":[],"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/manoj-lk-code.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}},"created_at":"2023-03-03T13:32:50.000Z","updated_at":"2024-12-14T01:09:52.000Z","dependencies_parsed_at":"2024-02-07T18:44:47.277Z","dependency_job_id":null,"html_url":"https://github.com/manoj-lk-code/php-script-for-wordpress-backup","commit_stats":null,"previous_names":["manoj-wpzonify/php-script-for-wordpress-backup","manoj-lk-code/php-script-for-wordpress-backup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/manoj-lk-code/php-script-for-wordpress-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoj-lk-code%2Fphp-script-for-wordpress-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoj-lk-code%2Fphp-script-for-wordpress-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoj-lk-code%2Fphp-script-for-wordpress-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoj-lk-code%2Fphp-script-for-wordpress-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manoj-lk-code","download_url":"https://codeload.github.com/manoj-lk-code/php-script-for-wordpress-backup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoj-lk-code%2Fphp-script-for-wordpress-backup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272958400,"owners_count":25022051,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"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":[],"created_at":"2025-01-04T14:50:09.217Z","updated_at":"2025-08-31T08:33:33.235Z","avatar_url":"https://github.com/manoj-lk-code.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Script for WordPress Backup and Restore.\n\nThis PHP script allows you to generate a backup of your WordPress website and restore it when needed. Please note that shell execution needs to be enabled for PHP.\n\n## How to use:\n\nTo use this script, please follow these steps:\n\n1. Upload the `backup.php` file to your WordPress instance directory.\n2. In the terminal, run the following command: `php backup.php`. Alternatively, you can visit `YourDomain.com/backup.php`.\n3. Once the backup file is generated, download it to your local computer.\n\nTo restore the backup to a new host, please follow these steps:\n\n4. Install a fresh WordPress on your new host. This will allow the `restore.php` file to use the database details to restore the backup.\n5. Upload the locally downloaded backup file to the same directory where you installed the new WordPress. Alternatively, you can use `wget` to download the backup file.\n6. Upload the `restore.php` file to the same directory.\n7. In the terminal, run the following command: `php restore.php`.\n\n**Your restoration should now be complete.** \n\nPlease note that you will need to update your DNS records to point to the new host. Once the changes have propagated globally, your site should be accessible.\n\nIf you find this script useful, please feel free to share it with your friends.\n\n#\n#\n#\n\n## How it works:\n\n### What `backup.php` does\n\nWhen executed, `backup.php` performs the following tasks:\n\n1. Extracts the database credentials from the `wp-config.php` file.\n2. Exports the database with the file name `backup-wp-db-$random_string.sql`.\n3. Compresses all files with the file name `backup-wp-files-$random_string.zip` in the same directory. \n4. Deletes the SQL file, as it is no longer needed and is already compressed under the zip file.\n\n### What `restore.php` does\n\nWhen executed, `restore.php` performs the following tasks:\n\n1. Renames the `wp-config.php` file to `old-wp-config.php`.\n2. Deletes all files and folders that start with `wp-`, as well as the `index.php` and `xmlrpc.php` files.\n3. Extracts `backup-wp-files-$random_string.zip` to the same directory.\n4. Updates the `wp-config.php` file with the database credentials from the `old-wp-config.php` file.\n5. Drops all tables from the fresh WordPress instance database and imports the new database SQL with the file name `backup-wp-db-$random_string.sql`.\n\nThat's it! Although code to remove the zip and SQL files is not included, you can manually remove them as they are no longer needed.\n\n# Credits\n\nThis code is created using ChatGPT and inspired from the article by [Manoj](https://manojlk.work): Read article: [How to migrate WordPress manually but faster \u0026 better.](https://wpzonify.com/how-to-migrate-your-wordpress-site-manually/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanoj-lk-code%2Fphp-script-for-wordpress-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanoj-lk-code%2Fphp-script-for-wordpress-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanoj-lk-code%2Fphp-script-for-wordpress-backup/lists"}