PHPackages                             karim-dev/smart-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. [File &amp; Storage](/categories/file-storage)
4. /
5. karim-dev/smart-backup

ActiveLibrary[File &amp; Storage](/categories/file-storage)

karim-dev/smart-backup
======================

A Laravel package for creating and managing database and storage backups.

v1.0.7(1mo ago)216↓100%MITPHPPHP ^8.2

Since May 8Pushed 1mo agoCompare

[ Source](https://github.com/Kareem154/SmartBckup)[ Packagist](https://packagist.org/packages/karim-dev/smart-backup)[ RSS](/packages/karim-dev-smart-backup/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (8)Used By (0)

Smart Backup
============

[](#smart-backup)

A simple Laravel package for creating and managing database and storage backups.

Smart Backup uses `spatie/laravel-backup` internally, but adds a cleaner workflow:

- Creates database and storage backups.
- Saves backup records in the database.
- Provides Artisan commands.
- Provides optional routes for dashboard/API usage.
- Supports single delete and bulk delete.
- Automatically detects `mysqldump` when possible.
- Saves backups in one managed folder, default: `backups`.

---

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

[](#requirements)

- PHP `^8.2`
- Laravel `^11.0|^12.0|^13.0`
- MySQL/MariaDB requires `mysqldump`

---

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

[](#installation)

```
composer require karim-dev/smart-backup
```

If Composer needs to update related dependencies:

```
composer require karim-dev/smart-backup -W
```

Publish config and migration:

```
php artisan smart-backup:install
php artisan migrate
```

> `smart-backup:install` already publishes the migration. Do not publish the migration again unless you need another copy.

---

Usage
-----

[](#usage)

Create a full backup (database + storage):

```
php artisan smart-backup:run
```

Create a database-only backup:

```
php artisan smart-backup:database
```

Create a storage-only backup:

```
php artisan smart-backup:storage
```

List backups:

```
php artisan smart-backup:list
```

Delete a backup:

```
php artisan smart-backup:delete {id}
```

Force delete:

```
php artisan smart-backup:delete {id} --force
```

---

What Is Backed Up?
------------------

[](#what-is-backed-up)

By default, Smart Backup includes:

```
storage/app
storage/demo

```

`storage/demo` is included only if it exists.

Smart Backup does **not** back up the full Laravel project.

It does not include:

```
.env
vendor/
app/
routes/
resources/
storage/framework/
storage/logs/

```

---

Backup Location
---------------

[](#backup-location)

By default, backups are saved in:

```
storage/app/private/backups

```

Example:

```
storage/app/private/
└── backups/
    ├── 2026-05-09-01-00-51.zip
    └── 2026-05-09-01-01-48.zip

```

Smart Backup avoids keeping extra folders named after the project, such as:

```
storage/app/private/zamil
storage/app/private/Laravel

```

The final backup files should be kept inside the managed `backups` folder.

---

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

[](#configuration)

The config file is published here:

```
config/smart-backup.php

```

Most projects do **not** need to add anything to `.env`.

Optional `.env` values:

```
SMART_BACKUP_DISK=local
SMART_BACKUP_DIRECTORY=backups
SMART_BACKUP_KEEP_BACKUPS=true
SMART_BACKUP_PREVENT_DELETE_LAST=true
SMART_BACKUP_MYSQL_DUMP_BINARY_PATH=
SMART_BACKUP_MYSQL_DUMP_TIMEOUT=300
SMART_BACKUP_MYSQL_SINGLE_TRANSACTION=true
```

---

Optional Settings
-----------------

[](#optional-settings)

### Change backup folder

[](#change-backup-folder)

Default:

```
SMART_BACKUP_DIRECTORY=backups
```

Example:

```
SMART_BACKUP_DIRECTORY=system-backups
```

---

### Keep only the latest backup

[](#keep-only-the-latest-backup)

Default is to keep all backups:

```
SMART_BACKUP_KEEP_BACKUPS=true
```

To delete old backups after a successful new backup:

```
SMART_BACKUP_KEEP_BACKUPS=false
```

---

### Prevent deleting the last backup

[](#prevent-deleting-the-last-backup)

Default:

```
SMART_BACKUP_PREVENT_DELETE_LAST=true
```

---

### Custom `mysqldump` path

[](#custom-mysqldump-path)

Normally, you do not need this.

Smart Backup tries to detect `mysqldump` automatically from common paths like XAMPP, Laragon, WAMP, `/usr/bin`, and `/usr/local/bin`.

If detection fails, set:

```
SMART_BACKUP_MYSQL_DUMP_BINARY_PATH=C:/xampp/mysql/bin
```

or on Linux/cPanel:

```
SMART_BACKUP_MYSQL_DUMP_BINARY_PATH=/usr/bin
```

You do **not** need to edit `config/database.php`.

---

Routes
------

[](#routes)

Smart Backup registers a route macro.

It does not load routes automatically, so you can register the routes wherever you want in your Laravel application.

### Basic usage

[](#basic-usage)

```
use Illuminate\Support\Facades\Route;

Route::smartBackup();
```

This will register the following routes:

```
GET     /backup                     backup.index
POST    /backup                     backup.store
GET     /backup/{backup}/download   backup.download
DELETE  /backup/{backup}            backup.destroy
DELETE  /backup                     backup.bulk-destroy

```

You can use the route names like this:

```
route('backup.index');
route('backup.store');
route('backup.download', $backup);
route('backup.destroy', $backup);
route('backup.bulk-destroy');
```

---

### Creating Backups via API / Dashboard

[](#creating-backups-via-api--dashboard)

When creating a backup via the `backup.store` endpoint (POST `/backup`), the process runs as a **Queue Job** (`RunSmartBackupJob`) in the background. This ensures your web requests never timeout.

You can specify the backup type by passing it in the JSON payload.

**Full Backup:**

```
{
    "type": "full"
}
```

**Database Only:**

```
{
    "type": "database"
}
```

**Storage Only:**

```
{
    "type": "storage"
}
```

The endpoint will respond instantly with:

```
{
    "success": true,
    "queued": true,
    "message": "تم وضع النسخة الاحتياطية في الطابور بنجاح وسيتم تنفيذها في الخلفية."
}
```

> **Note:** If your `.env` is set to `QUEUE_CONNECTION=sync`, the backup will run immediately and wait to finish. If set to `database` or `redis`, you must have `php artisan queue:work` running on your server.

---

### Dashboard usage

[](#dashboard-usage)

You can register Smart Backup routes inside your dashboard route group:

```
use Illuminate\Support\Facades\Route;

Route::prefix('dashboard')
    ->name('dashboard.')
    ->middleware(['web', 'auth'])
    ->group(function () {
        Route::smartBackup();
    });
```

This will register the following routes:

```
GET     /dashboard/backup                     dashboard.backup.index
POST    /dashboard/backup                     dashboard.backup.store
GET     /dashboard/backup/{backup}/download   dashboard.backup.download
DELETE  /dashboard/backup/{backup}            dashboard.backup.destroy
DELETE  /dashboard/backup                     dashboard.backup.bulk-destroy

```

You can use the route names like this:

```
route('dashboard.backup.index');
route('dashboard.backup.store');
route('dashboard.backup.download', $backup);
route('dashboard.backup.destroy', $backup);
route('dashboard.backup.bulk-destroy');
```

---

### Bulk delete

[](#bulk-delete)

The bulk delete route is:

```
DELETE /backup

```

If you register the routes inside a dashboard group, it becomes:

```
DELETE /dashboard/backup

```

The route name will be:

```
route('backup.bulk-destroy');
```

Or inside dashboard:

```
route('dashboard.backup.bulk-destroy');
```

It expects an array of backup IDs:

```
{
    "ids": [1, 2, 3]
}
```

Blade form example:

```

    @csrf
    @method('DELETE')

    Delete selected backups

```

AJAX example:

```
fetch("{{ route('dashboard.backup.bulk-destroy') }}", {
    method: "DELETE",
    headers: {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "X-CSRF-TOKEN": "{{ csrf_token() }}"
    },
    body: JSON.stringify({
        ids: [1, 2, 3]
    })
});
```

---

### Custom prefix and route name

[](#custom-prefix-and-route-name)

You can customize the route prefix and route name:

```
use Illuminate\Support\Facades\Route;

Route::smartBackup([
    'prefix' => 'backups',
    'name' => 'backups.',
]);
```

This will register routes like:

```
GET     /backups                     backups.index
POST    /backups                     backups.store
GET     /backups/{backup}/download   backups.download
DELETE  /backups/{backup}            backups.destroy
DELETE  /backups                     backups.bulk-destroy

```

You can use them like this:

```
route('backups.index');
route('backups.store');
route('backups.download', $backup);
route('backups.destroy', $backup);
route('backups.bulk-destroy');
```

---

### Custom dashboard prefix and route name

[](#custom-dashboard-prefix-and-route-name)

You can also combine dashboard grouping with custom Smart Backup options:

```
use Illuminate\Support\Facades\Route;

Route::prefix('dashboard')
    ->name('dashboard.')
    ->middleware(['web', 'auth'])
    ->group(function () {
        Route::smartBackup([
            'prefix' => 'backups',
            'name' => 'backups.',
        ]);
    });
```

This will register routes like:

```
GET     /dashboard/backups                     dashboard.backups.index
POST    /dashboard/backups                     dashboard.backups.store
GET     /dashboard/backups/{backup}/download   dashboard.backups.download
DELETE  /dashboard/backups/{backup}            dashboard.backups.destroy
DELETE  /dashboard/backups                     dashboard.backups.bulk-destroy

```

You can use them like this:

```
route('dashboard.backups.index');
route('dashboard.backups.store');
route('dashboard.backups.download', $backup);
route('dashboard.backups.destroy', $backup);
route('dashboard.backups.bulk-destroy');
```

---

Notes
-----

[](#notes)

Use Smart Backup command:

```
php artisan smart-backup:run
```

Do not use Spatie directly when testing this package:

```
php artisan backup:run
```

because Smart Backup adds runtime configuration, database records, managed folder behavior, and cleanup logic.

---

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

[](#troubleshooting)

### `mysqldump` is not recognized

[](#mysqldump-is-not-recognized)

Set the path manually:

```
SMART_BACKUP_MYSQL_DUMP_BINARY_PATH=C:/xampp/mysql/bin
```

Then run:

```
php artisan optimize:clear
php artisan smart-backup:run
```

---

### `Mailer [] is not defined`

[](#mailer--is-not-defined)

For local testing, add:

```
MAIL_MAILER=log
```

Then run:

```
php artisan optimize:clear
```

---

### Duplicate migration

[](#duplicate-migration)

If you published the migration twice, delete the extra migration file before running:

```
php artisan migrate
```

---

Author
------

[](#author)

**Karim Mohamed**

Package: `karim-dev/smart-backup`

GitHub: [Kareem154](https://github.com/Kareem154)

---

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

7

Last Release

30d ago

### Community

Maintainers

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

---

Top Contributors

[![Kareem154](https://avatars.githubusercontent.com/u/129125061?v=4)](https://github.com/Kareem154 "Kareem154 (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/karim-dev-smart-backup/health.svg)

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

###  Alternatives

[illuminate/filesystem

The Illuminate Filesystem package.

15163.8M3.0k](/packages/illuminate-filesystem)[spatie/laravel-backup-server

Backup multiple applications

17119.3k1](/packages/spatie-laravel-backup-server)

PHPackages © 2026

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