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

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

redaelfillali/laravel-backup
============================

Laravel Backup solution for shared hosting

1.1.1(4mo ago)11.1k—7.1%MITPHPPHP ^8.1CI passing

Since Nov 22Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/redafillali/laravel-backup)[ Packagist](https://packagist.org/packages/redaelfillali/laravel-backup)[ RSS](/packages/redaelfillali-laravel-backup/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (6)Dependencies (9)Versions (16)Used By (0)

redaelfillali/laravel-backup
============================

[](#redaelfillalilaravel-backup)

A simple Laravel package for backing up files and databases with support for different backup types and scheduling. This package allows you to perform backups without the use of `proc_open`, and can be triggered via a console command or a custom controller route.

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

[](#requirements)

- Laravel: ^10.0 | ^11.0 | ^12.0
- PHP:
    - For Laravel 10: ^8.1
    - For Laravel 11 and 12: ^8.2

Features
--------

[](#features)

- **Backup Path**: Easily set the destination folder for backups.
- **Backup Types**:
    - Full Backup (both files and database)
    - Files Only
    - Database Only
- **No `proc_open` Dependency**: The package works without relying on `proc_open`, ensuring compatibility with restrictive hosting environments.
- **Command and Controller Support**: Can be used via a console command or integrated into your application with a custom controller and route.
- **Scheduled Backups**: Utilize Laravel's task scheduling system to automate backups.
- **Retention Cleanup**: When running database backups, the package automatically deletes backup files older than a configurable number of days from the configured `backup.path` directory.

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

[](#installation)

You can install this package via Composer:

```
composer require redaelfillali/laravel-backup
```

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

[](#configuration)

After installation, publish the configuration file using the following Artisan command:

```
php artisan vendor:publish --provider="Redaelfillali\LaravelBackup\BackupServiceProvider"
```

This will copy the configuration file to the `config/backup.php` file, where you can adjust settings such as the backup path, timeout, and retention period.

Usage
-----

[](#usage)

### Running Backups via Command

[](#running-backups-via-command)

You can run a backup using the following Artisan command:

```
php artisan backup:run
```

Specify a backup type (`full`, `files`, or `database`):

```
php artisan backup:run full
php artisan backup:run database
php artisan backup:run files
```

Override the backup path:

```
php artisan backup:run full --path=/your/custom/path
```

### Running Backups via Controller

[](#running-backups-via-controller)

You can trigger a backup by sending a POST request to the built-in routes or by calling `BackupManager` directly:

```
use Redaelfillali\LaravelBackup\Helpers\BackupManager;

class BackupController extends Controller
{
    public function createBackup()
    {
        BackupManager::backup('full', config('backup.path'));

        return response()->json(['message' => 'Backup completed successfully']);
    }
}
```

### Built-in Routes

[](#built-in-routes)

The package registers the following POST routes automatically:

MethodURIDescriptionPOST`/backup/run`Run a backup (pass `type` and optional `path` in the request body)POST`/backup/database`Run a database-only backupPOST`/backup/files`Run a files-only backupExample request using the `/backup/run` route:

```
Route::post('/trigger-backup', function () {
    return Http::post(url('/backup/run'), ['type' => 'database']);
});
```

### Scheduling Backups

[](#scheduling-backups)

You can schedule backups using Laravel's task scheduling system. Add the following to your `App\Console\Kernel` class (Laravel 10) or `routes/console.php` (Laravel 11+):

**Laravel 10 — `app/Console/Kernel.php`:**

```
use Illuminate\Console\Scheduling\Schedule;

protected function schedule(Schedule $schedule)
{
    $schedule->command('backup:run database')
             ->daily();
}
```

**Laravel 11+ — `routes/console.php`:**

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('backup:run database')->daily();
```

### Custom Route Definition

[](#custom-route-definition)

If you prefer to define your own route, you can do so by calling `BackupManager` directly:

```
use Redaelfillali\LaravelBackup\Helpers\BackupManager;

Route::post('/backup', function () {
    BackupManager::backup('full', config('backup.path'));
    return response()->json(['message' => 'Backup completed successfully']);
})->middleware('auth');
```

> **Note:** It is strongly recommended to protect backup routes with authentication middleware to prevent unauthorised access.

Configuration Reference
-----------------------

[](#configuration-reference)

KeyDefaultDescription`path``storage/backups/Y/m/d`Destination directory for backup files`types``['full', 'files', 'database']`Available backup types`timeout``3600`Maximum execution time in seconds`retention_period``7`Days to keep old backups before automatic deletion`backup_name``backup-Y-m-d-H-i-s`Filename prefix for database backup files`enable_notifications``true`Enable/disable backup notificationsTesting
-------

[](#testing)

The package includes a full test suite built with [PHPUnit](https://phpunit.de) and [Orchestra Testbench](https://packages.tools/testbench).

### Running the Tests

[](#running-the-tests)

Install the development dependencies and run the test suite:

```
composer install
composer test
```

Or run PHPUnit directly:

```
./vendor/bin/phpunit
```

### Test Structure

[](#test-structure)

```
tests/
├── TestCase.php                       # Base test case (Orchestra Testbench)
├── Unit/
│   └── BackupManagerTest.php          # Unit tests for BackupManager
└── Feature/
    ├── BackupCommandTest.php          # Feature tests for the Artisan command
    └── BackupControllerTest.php       # Feature tests for the HTTP routes

```

SuiteFileTestsUnit`BackupManagerTest`Directory creation, zip validity, no duplicate entries, SQL dump content, PDO quoting, null value handling, dynamic DB connection, retention cleanup, full backupFeature`BackupCommandTest`All backup types, default type, configured path, exception → exit code 1Feature`BackupControllerTest`All three routes, invalid type → HTTP 422, exception → HTTP 500License
-------

[](#license)

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

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance77

Regular maintenance activity

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~51 days

Recently: every ~113 days

Total

10

Last Release

125d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/262098756?v=4)[REDA EL FILLALI](/maintainers/redaelfillali)[@redaelfillali](https://github.com/redaelfillali)

---

Top Contributors

[![redafillali](https://avatars.githubusercontent.com/u/20681013?v=4)](https://github.com/redafillali "redafillali (18 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[illuminate/filesystem

The Illuminate Filesystem package.

16165.1M3.2k](/packages/illuminate-filesystem)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[dgtlss/capsule

A Laravel package for backing up databases and files to external sources with notifications

196.0k](/packages/dgtlss-capsule)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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