PHPackages                             mikailfaruqali/backup - 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. mikailfaruqali/backup

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

mikailfaruqali/backup
=====================

Generate on-demand MySQL database backups and download them as password-protected, AES‑256 encrypted ZIP files via a simple HTTP route.

1.3.3(5mo ago)091↓93.3%MITPHPPHP &gt;=7.4

Since Jun 1Pushed 5mo agoCompare

[ Source](https://github.com/mikailfaruqali/backup)[ Packagist](https://packagist.org/packages/mikailfaruqali/backup)[ Docs](https://github.com/mikailfaruqali/backup)[ RSS](/packages/mikailfaruqali-backup/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (5)Versions (8)Used By (0)

Laravel Backup Package
======================

[](#laravel-backup-package)

[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

Generate on-demand MySQL database backups and download them as password-protected, AES‑256 encrypted ZIP files via a simple HTTP route.

Built for simplicity, performance, and easy integration into existing Laravel apps.

Features
--------

[](#features)

- One-click/download database backup via HTTP route
- ZIP encryption using AES‑256 (ZipArchive::EM\_AES\_256)
- Password protection for the ZIP file
- Configurable route prefix and middleware
- Customizable download filename
- Support for custom mysqldump binary path (Windows/Linux/macOS)
- Streams response and cleans up temporary files automatically

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Laravel framework (or illuminate/contracts) &gt;= 5.0
- PHP ZipArchive extension enabled
- MySQL database connection configured in `config/database.php`
- [spatie/db-dumper](https://github.com/spatie/db-dumper) (installed as a dependency)

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

[](#installation)

Install via Composer:

```
composer require mikailfaruqali/backup
```

Laravel will auto-discover the service provider.

Configuration
-------------

[](#configuration)

Publish the configuration file to your app (it will create `config/snawbar-backup.php`):

```
php artisan vendor:publish --provider="Snawbar\Backup\BackupServiceProvider" --tag="snawbar-backup-config"
```

Available options (defaults shown):

```
return [
		// Middleware applied to the backup route(s)
		'middleware' => ['web'],

		// Route prefix used by the package
		'route' => 'backup',

		// The downloadable ZIP file name (string). Avoid closures when using config cache.
		'file_name' => 'backup.zip',

		// The password required to open the ZIP
		'zip_password' => 'snawbar',

		// Absolute path to mysqldump if it's not in PATH
		// e.g. Windows: 'C:/xampp/mysql/bin/mysqldump.exe'
		//      Linux/macOS: '/usr/bin/mysqldump'
		'mysql_dump_path' => '',
];
```

Notes:

- The package code will also accept callables for `file_name` and `zip_password`. However, Laravel's config cache cannot serialize closures. Prefer static strings in your config file. If you need dynamic values, set them at runtime (e.g., in middleware) using `config([...])` before the request hits the controller, and avoid caching config or provide a non-closure value when cached.

Routes and Usage
----------------

[](#routes-and-usage)

This package registers the following route by default:

- GET `/{prefix}/download` → streams a password-protected ZIP containing a MySQL dump

Where `{prefix}` is the value of `snawbar-backup.route` (default: `backup`).

Examples:

- Default URL: `/backup/download`
- Custom prefix `admin/backup`: `/admin/backup/download`

The route name is `snawbar.backup.download`.

### Downloading a backup

[](#downloading-a-backup)

- Visit the route in your browser, e.g. `https://your-app.test/backup/download`
- Or using curl:

```
curl -L -o backup.zip https://your-app.test/backup/download
```

The response is a streamed download of an encrypted ZIP whose filename is taken from `snawbar-backup.file_name`. Use the password from `snawbar-backup.zip_password` to open the archive.

Security and Access Control
---------------------------

[](#security-and-access-control)

The download route is as secure as the middleware you attach to it. By default it uses the `web` middleware group only. You should restrict access in production.

Recommended options:

- Require authentication: set `'middleware' => ['web', 'auth']`
- Restrict to authorized roles/abilities: `'middleware' => ['web', 'auth', 'can:download-backup']`
- Use IP allow-lists or custom middleware for extra checks
- Consider signed routes or additional secrets when exposing via the internet

Update `config/snawbar-backup.php` accordingly and clear caches:

```
php artisan config:clear; php artisan route:clear
```

Database Connection
-------------------

[](#database-connection)

Backups use your default `mysql` connection from `config/database.php`:

- Host: `database.connections.mysql.host`
- Database: `database.connections.mysql.database`
- Username: `database.connections.mysql.username`
- Password: `database.connections.mysql.password`

Ensure these are set (typically via your `.env`).

mysqldump Path (especially on Windows)
--------------------------------------

[](#mysqldump-path-especially-on-windows)

If `mysqldump` isn't available in the system PATH, set `mysql_dump_path` in `config/snawbar-backup.php`:

- Windows (XAMPP example): `C:/xampp/mysql/bin/mysqldump.exe`
- WSL/Linux: `/usr/bin/mysqldump`
- macOS (Homebrew): `/opt/homebrew/bin/mysqldump` or `/usr/local/bin/mysqldump`

How it Works
------------

[](#how-it-works)

Under the hood (simplified):

1. Create a temporary `.sql` dump using spatie/db-dumper and `mysqldump`.
2. Create a temporary `.zip` with ZipArchive, set password and AES‑256 encryption, add the SQL file.
3. Stream the ZIP to the client as the response filename from `file_name`.
4. Delete the temporary files after streaming.

Troubleshooting
---------------

[](#troubleshooting)

- ZIP won't open / wrong password

    - Verify `zip_password` in `config/snawbar-backup.php`
    - Ensure no whitespace or unexpected characters
- 500 error: Failed to create ZIP archive

    - Confirm PHP ZipArchive extension is installed and enabled
    - Ensure the PHP process can write to the temp directory (`sys_get_temp_dir()`)
- mysqldump not found or permission denied

    - Set `mysql_dump_path` to the absolute path of `mysqldump`
    - Ensure the PHP user can execute `mysqldump`
- Empty or partial dump

    - Check DB credentials in `config/database.php`
    - Large databases may require increasing PHP `max_execution_time` and memory limits
- Route not found

    - Clear caches: `php artisan route:clear; php artisan config:clear`
    - Confirm your app is loading package routes and provider (auto-discovery)

Limitations and Notes
---------------------

[](#limitations-and-notes)

- Currently supports the default `mysql` connection. For other drivers, extend the controller as needed.
- Configuration closures are not compatible with `php artisan config:cache`.
- The backup is generated on-demand per request; there's no scheduled/queued command included by default.

API Surface (Package Internals)
-------------------------------

[](#api-surface-package-internals)

- Service Provider: `Snawbar\Backup\BackupServiceProvider`
- Controller: `Snawbar\Backup\Http\Controllers\BackupController`
- Route file: `src/routes/web.php`
- Config file: `config/backup.php` (published as `config/snawbar-backup.php`)

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

[](#contributing)

Issues and PRs are welcome. Please run code style and static analysis before submitting.

```
vendor\bin\pint
vendor\bin\phpstan analyse
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Author
------

[](#author)

Snawbar —

Links
-----

[](#links)

- GitHub:

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance70

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~38 days

Recently: every ~57 days

Total

7

Last Release

170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d45fe3050e046bb7e5b6b0a05fe3f96901b89638f6980c386cf570005a464865?d=identicon)[mikailfaruqali](/maintainers/mikailfaruqali)

---

Top Contributors

[![mikailfaruqali](https://avatars.githubusercontent.com/u/77926586?v=4)](https://github.com/mikailfaruqali "mikailfaruqali (11 commits)")

---

Tags

laravelencryptiondatabasebackupzipsnawbar

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k24.4M244](/packages/spatie-laravel-backup)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[kreait/laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

1.3k18.7M49](/packages/kreait-laravel-firebase)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213420.9k2](/packages/wnx-laravel-backup-restore)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3829.0k](/packages/orptech-laravel-migration-partition)[ntanduy/cloudflare-d1-database

Cloudflare D1 database driver for Laravel — full Eloquent &amp; Query Builder support.

267.8k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

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