PHPackages                             jpbgomes/laravel-database-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. jpbgomes/laravel-database-backup

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

jpbgomes/laravel-database-backup
================================

A simple Laravel package to backup MySQL databases and send them via email.

1.1.0(2mo ago)088MITPHPPHP &gt;=8.0

Since Sep 21Pushed 2mo agoCompare

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

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

Laravel Database Backup
=======================

[](#laravel-database-backup)

A simple Laravel package to back up your **MySQL or MariaDB** database and send the backup file via email, now with optional ZIP compression, password protection, and extra file/folder inclusion.

> ⚠️ Only MySQL/MariaDB are supported currently, since the package relies on `mysqldump`.

---

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

[](#-installation)

Require the package via Composer (from Packagist):

```
composer require jpbgomes/laravel-database-backup
```

Laravel will auto-discover the service provider. If not, add it manually to `config/app.php`:

```
'providers' => [
    Jpbgomes\DatabaseBackup\BackupServiceProvider::class,
]
```

Publish the config file:

```
php artisan vendor:publish --provider="Jpbgomes\\DatabaseBackup\\BackupServiceProvider" --tag=config
```

---

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

[](#️-configuration)

Edit `config/backup.php` after publishing:

```
return [
    'path' => storage_path('app/backups'),
    'recipients' => array_filter(array_map('trim', explode(',', env('BACKUP_EMAIL', 'admin@example.com')))),
    'zip_password' => env('BACKUP_ZIP_PASSWORD', null),
    'include' => [
        // '.env',
        // 'storage/app/public',
    ],
    'keep_local' => false,
];
```

Set your backup recipients and optional ZIP password in `.env`:

```
BACKUP_EMAIL=jpbgomesbusiness@gmail.com,arroz@gmail.com
BACKUP_ZIP_PASSWORD=
```

---

### Mailer Configuration

[](#mailer-configuration)

You must configure Laravel’s mailer to send the backups. A **free recommended option** is Gmail, but you must enable **2-Factor Authentication** and create an **App Password**.

Example `.env`:

```
MAIL_MAILER=smtp
MAIL_SCHEME=null
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=your_email@gmail.com
MAIL_PASSWORD='your_app_password'
MAIL_FROM_ADDRESS="your_email@gmail.com"
MAIL_FROM_NAME="${APP_NAME}"
```

---

📝 Usage
-------

[](#-usage)

Run the backup command:

```
php artisan backup:database
```

This will:

1. Create a `.sql` dump using `mysqldump`.
2. Generate a `.zip` file containing the SQL dump.
3. Optionally:

    - Protect the zip with a password.
    - Include extra folders/files in the zip.
4. Send the ZIP file to all configured recipients.
5. Optionally remove the local ZIP file.

---

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

[](#️-advanced-configuration)

### Multiple Recipients

[](#multiple-recipients)

```
BACKUP_EMAIL=email1@gmail.com,email2@gmail.com
```

### Password Protect ZIP

[](#password-protect-zip)

```
BACKUP_ZIP_PASSWORD=YourStrongPassword
```

If empty, the ZIP will not be encrypted.

### Include Additional Files/Folders

[](#include-additional-filesfolders)

Edit `config/backup.php`:

```
'include' => [
    '.env',
    'storage/app/public',
],
```

Paths are relative to `base_path()`.

---

⏰ Automating Daily Backups
--------------------------

[](#-automating-daily-backups)

You can automate backups using `crontab`. Example to run **every day at 4 AM**:

```
0 4 * * * sudo php /path_to/your_project/artisan backup:database >> /dev/null 2>&1
```

> Adjust the path to your Laravel project’s `artisan` file.

---

🛡 Security Notes &amp; Caveats
------------------------------

[](#-security-notes--caveats)

- `mysqldump` must be installed and accessible to the PHP process user.
- DB credentials may appear briefly in process listings.
- For large databases, the backup is compressed in a ZIP.
- SQL file is never sent directly, reducing exposure.
- Password-protected ZIP uses AES-256 encryption.

---

🤝 Contributing &amp; Improvements
---------------------------------

[](#-contributing--improvements)

Suggestions for improvements:

- Support for other database types (Postgres, SQLite).
- Remote storage integrations (S3, Google Cloud, etc.).
- Unit and integration tests for the backup command.
- CI/CD pipeline for testing and releases.

---

📜 License
---------

[](#-license)

MIT — free to use, modify, and share.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance85

Actively maintained with recent releases

Popularity13

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

Total

2

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/811b0abe9f8fbc6c93875a637ff1421c7942f434abe843bbcf97422a74dfd142?d=identicon)[JPB Gomes](/maintainers/JPB%20Gomes)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php-laravel

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

1.7k35.6M74](/packages/aws-aws-sdk-php-laravel)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[backup-manager/laravel

Database backup manager seamlessly integrated with Laravel 4 or 5 with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more.

685793.4k2](/packages/backup-manager-laravel)[azure-oss/storage-blob-laravel

Azure Storage Blob filesystem driver for Laravel

63582.2k1](/packages/azure-oss-storage-blob-laravel)

PHPackages © 2026

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