PHPackages                             avcodewizard/laravel-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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. avcodewizard/laravel-backup

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

avcodewizard/laravel-backup
===========================

A Laravel package for database and storage backup with auto-cleanup.

1.0.0(1y ago)0161MITPHPPHP &gt;=8.0

Since Apr 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/avcodewizard/laravel-backup)[ Packagist](https://packagist.org/packages/avcodewizard/laravel-backup)[ RSS](/packages/avcodewizard-laravel-backup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

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

[](#-laravel-backup-package)

A simple Laravel package to automatically **backup your database and storage directory**, with a Blade-based UI to view, download, and delete backups.

---

🚀 Features
----------

[](#-features)

- 🔄 Daily backup of database and storage (`storage/app/public`)
- 🧼 Auto-delete backups older than configurable days (default 5 days)
- 🧾 List, download, and delete backups via Blade UI
- 👤 Access control using roles and middleware
- 🛠 Configurable via `config/laravelBackup.php`

---

📥 Installation
--------------

[](#-installation)

Install the package via composer:

```
composer require avcodewizard/laravel-backup
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Edit the config file at: `config/laravelBackup.php`

```
return [
    'backup_path' => storage_path('backups'),
    'keep_days' => 5, // Automatically delete backups older than 5 days
    'backup_storage_directory' => false, // true or false
    'check_access' => false, // Enable/disable role-based access to UI
    'allowed_roles' => [], // Role Names Example: ['Admin', 'Super-Admin','Developer', 'Manager']
];
```

- If you want's to backup storage directory

```
'backup_storage_directory' => true, // true or false

```

---

🛡️ Access Control
-----------------

[](#️-access-control)

To enable UI access control based on user roles:

1. Set `'check_access' => true`
2. Add roles in `'allowed_roles' => ['Admin']`
3. Ensure your `User` model has a `hasRole()` method (e.g., using [spatie/laravel-permission](https://github.com/spatie/laravel-permission))

Middleware used:
`Avcodewizard\LaravelBackup\Http\Middleware\CheckLaravelBackupAccess`

---

🖥️ Web Interface
----------------

[](#️-web-interface)

Access the UI at:

```
/laravel-backup

```

Example route setup (already included in the package):

```
Route::prefix('laravel-backup')
    ->middleware(['web', \Avcodewizard\LaravelBackup\Http\Middleware\CheckLaravelBackupAccess::class])
    ->group(function () {
        Route::get('/', [BackupController::class, 'index'])->name('laravel-backup.index');
        Route::get('/create', [BackupController::class, 'create'])->name('laravel-backup.create');
        Route::get('/download', [BackupController::class, 'download'])->name('laravel-backup.download');
        Route::delete('/delete', [BackupController::class, 'delete'])->name('laravel-backup.delete');
    });
```

---

🛠 Usage
-------

[](#-usage)

### Create Backup via Web

[](#create-backup-via-web)

1. Go to `/laravel-backup`
2. Click **Create Backup**

- If use want to create backup from ui, make sure to run the queue worker:

```
php artisan queue:work
```

### Create Backup via Terminal

[](#create-backup-via-terminal)

```
php artisan backup:run
```

---

🧹 Automatic Cleanup
-------------------

[](#-automatic-cleanup)

Backups older than `keep_days` will be deleted automatically.

### Add to Scheduler

[](#add-to-scheduler)

In `app/Console/Kernel.php`, add:

```
$schedule->command('backup:run')->daily();
```

---

📂 Backup Storage
----------------

[](#-backup-storage)

Backups are saved in:

```
storage/backups/

```

Each backup includes:

- `YYYY-MM-DD-HH-MM-SS_database.sql`
- `YYYY-MM-DD-HH-MM-SS_storage.zip`

---

🧑‍💻 Developer Notes
-------------------

[](#‍-developer-notes)

### Publish Config &amp; Views

[](#publish-config--views)

```
php artisan vendor:publish --tag=laravel-backup
```

This will publish:

- `config/laravelBackup.php`
- Blade views to `resources/views/vendor/laravel-backup/`

### Middleware Logic

[](#middleware-logic)

The package uses a configurable middleware to restrict access:

```
if (!config('laravelBackup.check_access')) return $next($request);

$user = Auth::user();
if (!$user) {
    abort(403, 'Unauthorized - no user authenticated.');
}

if (!method_exists($user, 'hasRole')) {
    abort(403, 'User Role Not Implemented!');
}

if (!$user->hasAnyRole(config('laravelBackup.allowed_roles'))) {
    abort(403, 'Unauthorized - insufficient permission.');
}

return $next($request);
```

You can customize access logic using roles or your own permission methods.

---

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

© 2025 [Avcodewizard](https://github.com/avcodewizard)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

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

Unknown

Total

1

Last Release

399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e19e6c2cab30c60bcd1f9c6794710aafef9703dccbfb59b346e3f648ca799a9?d=identicon)[avcodewizard](/maintainers/avcodewizard)

---

Top Contributors

[![avcodewizard](https://avatars.githubusercontent.com/u/45030401?v=4)](https://github.com/avcodewizard "avcodewizard (1 commits)")

---

Tags

auto-backupauto-cleanupbackupdatabase-backupdevopslaravellaravel-12laravel-applicationlaravel-frameworklaravel-packagephpphp-frameworkstorage-backupziplaravelbackupdatabase backupstorage backupauto-backupauto-cleanup

### Embed Badge

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

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

###  Alternatives

[timokoerber/laravel-one-time-operations

Run operations once after deployment - just like you do it with migrations!

6481.7M11](/packages/timokoerber-laravel-one-time-operations)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[thebytelab/vapor-multi-region-deploy

An artisan command to assist deploying your Laravel Vapor app to multiple AWS regions

162.2k](/packages/thebytelab-vapor-multi-region-deploy)

PHPackages © 2026

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