PHPackages                             rast/dbbackup - 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. rast/dbbackup

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

rast/dbbackup
=============

Simple MySQL backup package for Laravel

v1.11(3mo ago)026MITPHP

Since Nov 15Pushed 3mo agoCompare

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

READMEChangelog (10)DependenciesVersions (12)Used By (0)

📦 RAST DB Backup
================

[](#-rast-db-backup)

[![Issues](https://camo.githubusercontent.com/fe00ac0511dbd43d69e503dc437be546eb8041673bd4b9dbc2c4816141decaa4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f72616968616e6166726f7a2f64626261636b75703f7374796c653d666c61742d737175617265)](https://github.com/raihanafroz/dbbackup/issues)[![Forks](https://camo.githubusercontent.com/194ff951ae4f0023ae6105a7979bb5510faf36c0742259cfbb3f8e3ce8d53e89/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f72616968616e6166726f7a2f64626261636b75703f7374796c653d666c61742d737175617265)](https://github.com/raihanafroz/dbbackup/network/members)[![Stars](https://camo.githubusercontent.com/e11fd6dc80f890d3fddeb8f9264b26c6bcea94f0c326810fe108dc15fd37a89c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f72616968616e6166726f7a2f64626261636b75703f7374796c653d666c61742d737175617265)](https://github.com/raihanafroz/dbbackup/stargazers)[![Total Downloads](https://camo.githubusercontent.com/af72791ca8685de6699505073143834dba07253ace52069c0f27d2d4b4036a59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726173742f64626261636b75703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rast/dbbackup)[![License](https://camo.githubusercontent.com/89e81123ac0e0f5166844c1f83a8b25d9f55bd8e9f05fa4a9ccd91075c09b4c1/68747470733a2f2f706f7365722e707567782e6f72672f726173742f64626261636b75702f6c6963656e73652e737667)](https://packagist.org/packages/rast/dbbackup)

A lightweight Laravel package for creating MySQL database backups via CLI or scheduler.

**Features:**

- Custom backup directories
- Configurable `mysqldump` path
- Optional ZIP compression
- Optional email notification with backup attachment
- Restore backups from `.sql` or `.zip` files

---

🔧 Requirements
--------------

[](#-requirements)

- PHP 8.2+
- Laravel 12.x
- MySQL database
- `mysqldump` installed and executable on the server

---

🚀 Installation
--------------

[](#-installation)

### 1. Add the package to your project

[](#1-add-the-package-to-your-project)

```
composer require rast/dbbackup
```

### 2. Register the Service Provider

[](#2-register-the-service-provider)

If your package is not auto-discovered, add it in `config/app.php`:

```
'providers' => [
    // Other providers...
    RAST\DbBackup\DbBackupServiceProvider::class,
],
```

---

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

[](#️-configuration)

### 1. Publish the config

[](#1-publish-the-config)

```
php artisan vendor:publish --provider="RAST\DbBackup\DbBackupServiceProvider" --tag=config
```

This creates: `config/dbbackup.php`

### 2. Config Options

[](#2-config-options)

```
return [

    'backup_path' => storage_path('app/db_backups'),

    'mysql_path' => env('MYSQL_PATH', 'C:/xampp/mysql/bin'),

    'filename' => 'backup_{db}_{date}.sql',

    'compression' => [
        'enabled' => true,
        'type' => 'zip',
    ],

    'cleanup' => [
        'enabled' => true,
        'keep_last' => 10,
    ],

    'email' => [
        'enabled' => false,
        'from_name' => 'RAST',
        'from_address' => 'no-reply@nrast.com',
        'to' => 'admin@nrast.com',
        'subject' => 'Database Backup',
        'message' => 'Your database backup is attached.',
    ],

    'logging' => true,
];
```

**Key Options:**

OptionDescriptionbackup\_pathDirectory to store backupsmysqldump\_pathPath to `mysqldump` (full path recommended)filenameBackup file naming pattern (`{db}` and `{date}` supported)compressionEnable ZIP compressioncleanupAuto-delete old backups, keeps latest `n` filesemailSend backup via emailloggingLog backup actions to `laravel.log`### 3. Environment Variables

[](#3-environment-variables)

Add to `.env`:

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_user
DB_PASSWORD=your_password

#windows
MYSQL_PATH=C:/xampp/mysql/bin
#linux
MYSQL_PATH=/usr/bin
```

> On cPanel/shared hosting: usually `/usr/bin`On Windows/XAMPP: `C:/xampp/mysql/bin`

---

⚡ Usage
-------

[](#-usage)

### 1. Manual Backup

[](#1-manual-backup)

```
php artisan rast:db-backup
```

Example output:

```
Backup complete: storage/app/db_backups/backup_mydb_2025_11_15_173027.sql.zip

```

### 2. Optional Command Flags

[](#2-optional-command-flags)

FlagDescription--no-zipSkip compression--no-emailSkip email--no-cleanSkip deleting old backups--restoreRestore the old backupsBackup Example:

```
php artisan rast:db-backup --no-zip --no-email
```

Restore Example:

```
php artisan rast:db-backup --restore=backup.sql
```

- Supports .sql and .zip backups
- Automatically extracts .zip before restoring

```
php artisan rast:db-backup --restore=backup_mydb_2025_11_15_173027.sql.zip
```

### 3. Scheduling Backups

[](#3-scheduling-backups)

In `app/Console/Kernel.php`:

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('rast:db-backup')->dailyAt('03:00');
}
```

Add cron entry:

```
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
```

🔐 Security Recommendations
--------------------------

[](#-security-recommendations)

- Limit `backup_path` permissions: `chmod 770 storage/app/db_backups`
- Avoid storing backups in version control
- Optionally encrypt backup files (ZIP with password or GPG)
- For production, consider offloading backups to S3, FTP, or cloud storage

---

🛠 Troubleshooting
-----------------

[](#-troubleshooting)

IssueSolution`mysqldump: command not found`Set `MYSQL_DUMP_PATH` to full path: `/usr/bin/mysqldump`Permission denied writing fileEnsure `backup_path` exists and is writableBackup file emptyCheck DB credentials and privilegesEmail not sentVerify mail configuration in `.env`---

🔄 Extending the Package
-----------------------

[](#-extending-the-package)

- **Multiple databases**: Loop through multiple connections in `config/database.php`
- **Custom file names**: Include environment, app name, or custom prefix
- **Cloud storage**: Upload backups to S3, FTP, or remote servers
- **Additional compression formats**: `.gz`, `.tar.gz` using PHP functions or CLI tools

---

Made with ❤️ by **RAST**

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance79

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

Recently: every ~19 days

Total

11

Last Release

109d ago

### Community

Maintainers

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

---

Top Contributors

[![raihanafroz](https://avatars.githubusercontent.com/u/30098871?v=4)](https://github.com/raihanafroz "raihanafroz (16 commits)")

### Embed Badge

![Health badge](/badges/rast-dbbackup/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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