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(2mo ago)1891↓50%MITPHPPHP ^8.1CI passing

Since Nov 22Pushed 2mo 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 1mo ago

READMEChangelog (6)Dependencies (9)Versions (15)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

45

—

FairBetter than 92% of packages

Maintenance86

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

72d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/222f072ab7e75ce3f2ec27716be439688762069a980f5a60e6cc0b5a995170e0?d=identicon)[redaelfillali](/maintainers/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.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[nao-pon/flysystem-google-drive

Flysystem adapter for Google Drive

3672.0M20](/packages/nao-pon-flysystem-google-drive)[masbug/flysystem-google-drive-ext

Flysystem adapter for Google Drive with seamless virtual&lt;=&gt;display path translation

2631.7M14](/packages/masbug-flysystem-google-drive-ext)[dgtlss/capsule

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

194.3k](/packages/dgtlss-capsule)

PHPackages © 2026

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