{"id":14969114,"url":"https://github.com/watheqalshowaiter/backup-tables","last_synced_at":"2025-10-26T06:31:02.583Z","repository":{"id":254357004,"uuid":"844615628","full_name":"WatheqAlshowaiter/backup-tables","owner":"WatheqAlshowaiter","description":"Backup single or multiple database tables with ease.","archived":false,"fork":false,"pushed_at":"2025-02-06T10:11:26.000Z","size":379,"stargazers_count":26,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T19:03:50.154Z","etag":null,"topics":["laravel","laravel-package","model","mysql","php","php-package","postgresql","sql","sqlite","sqlserver","yemenopensource"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/watheqalshowaiter/backup-tables","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WatheqAlshowaiter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"WatheqAlshowaiter"}},"created_at":"2024-08-19T16:10:43.000Z","updated_at":"2025-02-06T10:11:29.000Z","dependencies_parsed_at":"2025-02-03T02:22:54.670Z","dependency_job_id":"880bec67-98ec-430d-8ebb-32143fb7b2e8","html_url":"https://github.com/WatheqAlshowaiter/backup-tables","commit_stats":{"total_commits":114,"total_committers":2,"mean_commits":57.0,"dds":"0.14912280701754388","last_synced_commit":"9b9b049233a8a849f220e0aaecbf85bba16af825"},"previous_names":["watheqalshowaiter/backup-tables"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WatheqAlshowaiter%2Fbackup-tables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WatheqAlshowaiter%2Fbackup-tables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WatheqAlshowaiter%2Fbackup-tables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WatheqAlshowaiter%2Fbackup-tables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WatheqAlshowaiter","download_url":"https://codeload.github.com/WatheqAlshowaiter/backup-tables/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238276072,"owners_count":19445344,"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":["laravel","laravel-package","model","mysql","php","php-package","postgresql","sql","sqlite","sqlserver","yemenopensource"],"created_at":"2024-09-24T13:41:08.887Z","updated_at":"2025-10-26T06:31:02.561Z","avatar_url":"https://github.com/WatheqAlshowaiter.png","language":"PHP","funding_links":["https://github.com/sponsors/WatheqAlshowaiter"],"categories":[],"sub_categories":[],"readme":"![Package cover](./arts/package-cover.png)\n\n# Backup Tables\n\n\u003c!-- shields --\u003e\n[![Required Laravel Version][ico-laravel]][link-packagist]\n[![Required PHP Version][ico-php]][link-packagist]\n[![Latest Version on Packagist][ico-version]][link-packagist]\n![GitHub Tests For Laravel Versions Action Status][ico-tests-for-laravel-versions]\n![GitHub Tests For Databases Action Status][ico-tests-for-databases]\n![GitHub Code Style Action Status][ico-code-style]\n[![Total Downloads][ico-downloads]][link-downloads]\n![GitHub Stars][ico-github-stars]\n[![StandWithPalestine][ico-palestine]][link-palestine]\n\n[ico-laravel]: https://img.shields.io/badge/Laravel-%E2%89%A56.0-ff2d20?style=flat-square\u0026logo=laravel\n[ico-php]: https://img.shields.io/packagist/php-v/watheqalshowaiter/backup-tables?color=%238892BF\u0026style=flat-square\u0026logo=php\n[ico-version]: https://img.shields.io/packagist/v/watheqalshowaiter/backup-tables.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/watheqalshowaiter/backup-tables.svg?style=flat-square\u0026color=%23007ec6\n[ico-code-style]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/backup-tables/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square\n[ico-tests-for-laravel-versions]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/backup-tables/tests-for-laravel-versions.yml?branch=main\u0026label=laravel%20versions%20tests\u0026style=flat-square\n[ico-tests-for-databases]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/backup-tables/tests-for-databases.yml?branch=main\u0026label=databases%20tests\u0026style=flat-square\n[ico-github-stars]: https://img.shields.io/github/stars/watheqalshowaiter/backup-tables?style=flat-square\n[ico-palestine]: https://raw.githubusercontent.com/TheBSD/StandWithPalestine/main/badges/StandWithPalestine.svg\n\n[link-packagist]: https://packagist.org/packages/watheqalshowaiter/backup-tables\n[link-downloads]: https://packagist.org/packages/watheqalshowaiter/backup-tables/stats\n[link-palestine]: https://github.com/TheBSD/StandWithPalestine/blob/main/docs/README.md\n\u003c!-- ./shields --\u003e\n\nBackup single or multiple database tables with ease.\n\n\u003e [!NOTE]\n\u003e If you want a full database backup with many features, go\n\u003e for [Spatie Laravel Backup](https://github.com/spatie/laravel-backup).\n\n## Installation\n\nYou can install the package via Composer:\n\n```sh\ncomposer require watheqalshowaiter/backup-tables\n```\n\n## Usage\n\nUse the `BackupTables::generateBackup($tableToBackup)` Facade anywhere in your application and it will\ngenerate `$tableToBackup_backup_2024_08_22_17_40_01` table in the database with all the data and structure. Note that\nthe datetime `2024_08_22_17_40_01` will be varied based on your datetime.\n\nYou can also use the `php artisan backup:tables \u003ctargets\u003e` command to back up tables,\nwhere `\u003ctargets\u003e` is a space-separated list of table names or models.\n\n```php\nuse WatheqAlshowaiter\\BackupTables\\BackupTables; // import the facade\n\nclass ChangeSomeData\n{\n    public function handle()\n    {\n        BackupTables::generateBackup('users');\n        // result: users_backup_2024_08_22_17_40_01\n       \n        // change some data..\n    }\n}\n```\n\nAnd More Customizations\n\n- You can use an array to back up more than one table\n\n```php\nBackupTables::generateBackup(['users', 'posts']); \n// users_backup_2024_08_22_17_40_01\n// posts_backup_2024_08_22_17_40_01 \n```\n\n- Or add Classes as parameters, It will backup their tables\n\n```php\nBackupTables::generateBackup(User::class);\n// users_backup_2024_08_22_17_40_01\n\n// or\n\nBackupTables::generateBackup([User::class, Post::class]);\n// users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01 \n```\n\n- You can customize the $dataTime format to whatever you want\n\n```php\nBackupTables::generateBackup('users', 'Y_d_m_H_i');\n// users_backup_2024_22_08_17_40\n```\n\n\u003e [!WARNING]\n\u003e When customizing the datetime format, be aware that backups with identical datetime values will be skipped.\n\u003e For example, if you use this `Y_d_m_H` you cannot generate the same backup in the same hour.\n\u003e The default format (Y_m_d_H_i_s) is recommended for most cases.\n\n```php\nBackupTables::generateBackup('users', 'Y_d_m_H');\n// can not generate the same backup in the same hour\n\nBackupTables::generateBackup('users', 'Y_d_m');\n// can not generate the same backup in the same day\n```\n\n- Using the artisan command for one or more tables/models\n\n```bash\nphp artisan backup:tables users posts\n# users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01\n\nphp artisan backup:tables \\\\App\\\\Models\\\\User \\\\App\\\\Models\\\\Post\n# users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01\n```\n\n## Why?\n\nSometimes you want to back up some database tables before changing data for whatever reason, this package serves this\nneed.\n\nI used it personally before adding foreign keys to tables that required removing unlinked fields from parent tables.\n\nYou may find some situation where you play with table data, or you're afraid of missing data, so you back up these\ntables\nbeforehand.\n\n## Features\n\n✅ Backup tables from the code using (Facade) or from the console command.\n\n✅ Supports Laravel versions: 12, 11, 10, 9, 8, 7, and 6.\n\n✅ Supports PHP versions: 8.4, 8.3, 8.2, 8.1, 8.0, and 7.4.\n\n✅ Supports SQL databases: SQLite, MySQL/MariaDB, PostgreSQL, and SQL Server.\n\n✅ Fully automated tested with PHPUnit.\n\n✅ Full GitHub Action CI pipeline to format code and test against all Laravel and PHP versions.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on recent changes.\n\n## Contributing\n\nIf you have any ideas or suggestions to improve it or fix bugs, your contribution is welcome.\n\nI encourage you to look at [issues](https://github.com/WatheqAlshowaiter/backup-tables/issues) which are the most\nimportant features\nthat need to be added.\n\nIf you have something different, submit an issue first to discuss or report a bug, then do a pull request.\n\n## Security Vulnerabilities\n\nIf you find any security vulnerabilities don't hesitate to contact me at `watheqalshowaiter[at]gmail[dot]com` to fix\nthem.\n\n## Related Packages\n\n- **[Model Fields](https://github.com/WatheqAlshowaiter/model-fields)** - Quickly retrieve required, nullable, and default fields for any Laravel model.\n- **[Filament Sticky Table Header](https://github.com/WatheqAlshowaiter/filament-sticky-table-header)** - Make Filament table headers stick when scrolling for better UX.\n\n## Credits\n\n- [Watheq Alshowaiter](https://github.com/WatheqAlshowaiter)\n- [Omar Alalwi](https://github.com/omaralalwi) - This package is based on his initial code.\n\n- [All Contributors](https://github.com/WatheqAlshowaiter/backup-tables/graphs/contributors)\n\nAnd a special thanks to [The King Creative](https://www.facebook.com/thkingcreative) for the logo ✨\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatheqalshowaiter%2Fbackup-tables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatheqalshowaiter%2Fbackup-tables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatheqalshowaiter%2Fbackup-tables/lists"}