PHPackages                             watheqalshowaiter/backup-tables - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. watheqalshowaiter/backup-tables

ActiveLibrary[Database &amp; ORM](/categories/database)

watheqalshowaiter/backup-tables
===============================

Backup single or multiple database tables with ease.

1.5.3(7mo ago)385302[2 PRs](https://github.com/WatheqAlshowaiter/backup-tables/pulls)MITPHPPHP &gt;=7.4CI passing

Since Aug 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/WatheqAlshowaiter/backup-tables)[ Packagist](https://packagist.org/packages/watheqalshowaiter/backup-tables)[ Docs](https://github.com/watheqalshowaiter/backup-tables)[ GitHub Sponsors](https://github.com/WatheqAlshowaiter)[ RSS](/packages/watheqalshowaiter-backup-tables/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (20)Used By (0)

[![Package cover](./arts/package-cover.png)](./arts/package-cover.png)

Backup Tables
=============

[](#backup-tables)

[![Required Laravel Version](https://camo.githubusercontent.com/ad12f0c8a4ddde25be583d748dd3124f1d88e04bb01479be92145352565d72cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d254532253839254135362e302d6666326432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://packagist.org/packages/watheqalshowaiter/backup-tables)[![Required PHP Version](https://camo.githubusercontent.com/6ad788405cea544c960c2f913436cb50fb48ad415f8b0c334c98e63791b84053/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f776174686571616c73686f7761697465722f6261636b75702d7461626c65733f636f6c6f723d253233383839324246267374796c653d666c61742d737175617265266c6f676f3d706870)](https://packagist.org/packages/watheqalshowaiter/backup-tables)[![Latest Version on Packagist](https://camo.githubusercontent.com/e4f45588742548a4afbede86e5a7453fceea806e7429fa8d8f14ca3f1f04c85f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776174686571616c73686f7761697465722f6261636b75702d7461626c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/watheqalshowaiter/backup-tables)[![GitHub Test Matrix Action Status](https://camo.githubusercontent.com/8353ee84e84a807ee82736436860d9046025df97fd05d4ec7d9d52eec77d389d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776174686571616c73686f7761697465722f6261636b75702d7461626c65732f746573742d6d61747269782e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8353ee84e84a807ee82736436860d9046025df97fd05d4ec7d9d52eec77d389d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776174686571616c73686f7761697465722f6261636b75702d7461626c65732f746573742d6d61747269782e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/c03d8869b5c08cd0b355d3860b28ab1bd14c017b7d20485d2d866cc8640fe660/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776174686571616c73686f7761697465722f6261636b75702d7461626c65732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/c03d8869b5c08cd0b355d3860b28ab1bd14c017b7d20485d2d866cc8640fe660/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776174686571616c73686f7761697465722f6261636b75702d7461626c65732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/7c3dd2d9335fcb9b4752e4202de3134f3dc0ec4864e6c09b87ee372ca10fe4cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776174686571616c73686f7761697465722f6261636b75702d7461626c65732e7376673f7374796c653d666c61742d73717561726526636f6c6f723d253233303037656336)](https://packagist.org/packages/watheqalshowaiter/backup-tables/stats)[![GitHub Stars](https://camo.githubusercontent.com/818e58ae6715b54d889308be0cbde7693927d75e6a2943365db449e506037418/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f776174686571616c73686f7761697465722f6261636b75702d7461626c65733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/818e58ae6715b54d889308be0cbde7693927d75e6a2943365db449e506037418/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f776174686571616c73686f7761697465722f6261636b75702d7461626c65733f7374796c653d666c61742d737175617265)[![StandWithPalestine](https://raw.githubusercontent.com/TheBSD/StandWithPalestine/main/badges/StandWithPalestine.svg)](https://github.com/TheBSD/StandWithPalestine/blob/main/docs/README.md)[![ko-fi](https://camo.githubusercontent.com/5e00067f5e4735d985d5936c33169a33b63c243a2f336dbdcc03c20f275b3320/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b6f2d2d66692d537570706f72742d6666356635663f6c6f676f3d6b6f2d6669267374796c653d666c61742d737175617265)](https://ko-fi.com/watheq_show)

Backup single or multiple database tables with ease.

Note

If you want a full database backup with many features, go for [Spatie Laravel Backup](https://github.com/spatie/laravel-backup).

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require watheqalshowaiter/backup-tables
```

Usage
-----

[](#usage)

Use the `BackupTables::generateBackup($tableToBackup)` Facade anywhere in your application and it will generate `$tableToBackup_backup_2024_08_22_17_40_01` table in the database with all the data and structure. Note that the datetime `2024_08_22_17_40_01` will be varied based on your datetime.

You can also use the `php artisan backup:tables ` command to back up tables, where `` is a space-separated list of table names or models.

```
use WatheqAlshowaiter\BackupTables\BackupTables; // import the facade

class ChangeSomeData
{
    public function handle()
    {
        BackupTables::generateBackup('users');
        // result: users_backup_2024_08_22_17_40_01

        // change some data..
    }
}
```

And More Customizations

- You can use an array to back up more than one table

```
BackupTables::generateBackup(['users', 'posts']);
// users_backup_2024_08_22_17_40_01
// posts_backup_2024_08_22_17_40_01
```

- Or add Classes as parameters, It will backup their tables

```
BackupTables::generateBackup(User::class);
// users_backup_2024_08_22_17_40_01

// or

BackupTables::generateBackup([User::class, Post::class]);
// users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01
```

- You can customize the $dataTime format to whatever you want

```
BackupTables::generateBackup('users', 'Y_d_m_H_i');
// users_backup_2024_22_08_17_40
```

Warning

When customizing the datetime format, be aware that backups with identical datetime values will be skipped. For example, if you use this `Y_d_m_H` you cannot generate the same backup in the same hour. The default format (Y\_m\_d\_H\_i\_s) is recommended for most cases.

```
BackupTables::generateBackup('users', 'Y_d_m_H');
// can not generate the same backup in the same hour

BackupTables::generateBackup('users', 'Y_d_m');
// can not generate the same backup in the same day
```

- Using the artisan command for one or more tables/models

```
php artisan backup:tables users posts
# users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01

php artisan backup:tables \\App\\Models\\User \\App\\Models\\Post
# users_backup_2024_08_22_17_40_01, posts_backup_2024_08_22_17_40_01
```

Why?
----

[](#why)

Sometimes you want to back up some database tables before changing data for whatever reason, this package serves this need.

I used it personally before adding foreign keys to tables that required removing unlinked fields from parent tables.

You may find some situation where you play with table data, or you're afraid of missing data, so you back up these tables beforehand.

Features
--------

[](#features)

✅ Backup tables from the code using (Facade) or from the console command.

✅ Supports Laravel versions: 12, 11, 10, 9, 8, 7, and 6.

✅ Supports PHP versions: 8.4, 8.3, 8.2, 8.1, 8.0, and 7.4.

✅ Supports SQL databases: SQLite, MySQL/MariaDB, PostgreSQL, and SQL Server.

✅ Fully automated tested with PHPUnit.

✅ Full GitHub Action CI pipeline to format code and test against all Laravel and PHP versions.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on recent changes.

Contributing
------------

[](#contributing)

If you have any ideas or suggestions to improve it or fix bugs, your contribution is welcome.

I encourage you to look at [issues](https://github.com/WatheqAlshowaiter/backup-tables/issues) which are the most important features that need to be added.

If you have something different, submit an issue first to discuss or report a bug, then do a pull request.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you find any security vulnerabilities don't hesitate to contact me at `watheqalshowaiter[at]gmail[dot]com` to fix them.

Related Packages
----------------

[](#related-packages)

- **[Model Fields](https://github.com/WatheqAlshowaiter/model-fields)** - Quickly retrieve required, nullable, and default fields for any Laravel model.
- **[Filament Sticky Table Header](https://github.com/WatheqAlshowaiter/filament-sticky-table-header)** - Make Filament table headers stick when scrolling for better UX.

Support this project
--------------------

[](#support-this-project)

If this project helps you, consider supporting it on [Ko-fi ☕](https://ko-fi.com/watheq_show).

Credits
-------

[](#credits)

- [Watheq Alshowaiter](https://github.com/WatheqAlshowaiter)
- [Omar Alalwi](https://github.com/omaralalwi) - This package is based on his initial code.
- [All Contributors](https://github.com/WatheqAlshowaiter/backup-tables/graphs/contributors)

And a special thanks to [The King Creative](https://www.facebook.com/thkingcreative) for the logo ✨

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance79

Regular maintenance activity

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~55 days

Total

11

Last Release

218d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46733da79a34ff686b036a09af1dcc6d21054aee25a5e029500dc87d3c69ba89?d=identicon)[WatheqAlshowaiter](/maintainers/WatheqAlshowaiter)

---

Top Contributors

[![WatheqAlshowaiter](https://avatars.githubusercontent.com/u/24838274?v=4)](https://github.com/WatheqAlshowaiter "WatheqAlshowaiter (189 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravellaravel-packagemodelmysqlphpphp-packagepostgresqlsqlsqlitesqlserveryemenopensourcephplaravelpackagemysqlsqlitepostgresqlmariadbsqlsqlservermodelWatheqAlshowaiterWatheq Alshowaiterphp-packageyemenopensourceyemen\_open\_sourcebackup tables

### Embed Badge

![Health badge](/badges/watheqalshowaiter-backup-tables/health.svg)

```
[![Health](https://phpackages.com/badges/watheqalshowaiter-backup-tables/health.svg)](https://phpackages.com/packages/watheqalshowaiter-backup-tables)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41234.1k4](/packages/aura-sqlschema)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
