PHPackages                             daiyan\_mozumder/flex-db-dump - 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. daiyan\_mozumder/flex-db-dump

ActiveLibrary

daiyan\_mozumder/flex-db-dump
=============================

Laravel database backup &amp; download package with SQL dump or PHP-only exporter

v2.0.2(3mo ago)06MITPHPPHP &gt;=8.1

Since Feb 9Pushed 3mo agoCompare

[ Source](https://github.com/DaiyanMozumder/flex-db-dump)[ Packagist](https://packagist.org/packages/daiyan_mozumder/flex-db-dump)[ RSS](/packages/daiyan-mozumder-flex-db-dump/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Flex DB Dump
============

[](#flex-db-dump)

Laravel database backup &amp; download package with **mysqldump** or **PHP-only exporter**.

Features
--------

[](#features)

- SQL dump (CLI)
- PHP-only exporter (shared hosting friendly)
- Config based mode switching
- Chunked export
- Auto download
- Secure &amp; lightweight

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

[](#installation)

```
     composer require daiyan_mozumder/flex-db-dump
```

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

[](#configuration)

```
     FLEX_DB_DUMP_MODE=php
```

Configuring mysqldump path
--------------------------

[](#configuring-mysqldump-path)

flex-db-dump uses mysqldump to create database backups. By default, it tries to run mysqldump from the system PATH. Depending on your environment, you may need to explicitly set the path.

Step 1: Publish the config
--------------------------

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

Publish Config
--------------

[](#publish-config)

```
     php artisan vendor:publish --tag=flex-db-dump-config
```

This will create:

```
     config/flex_db_dump.php
```

Step 2: Update the mysqldump\_path
----------------------------------

[](#step-2-update-the-mysqldump_path)

Open config/flex\_db\_dump.php:

```
     return [
    // Backup storage path
    'path' => storage_path('app/db_backups'),

    // Full path to mysqldump executable
    'mysqldump_path' => env('MYSQLDUMP_PATH', 'mysqldump'), // default
];
```

Step 3: Set environment variable in .env
----------------------------------------

[](#step-3-set-environment-variable-in-env)

1️⃣ Local development

Windows (XAMPP, WAMP):

```
     MYSQLDUMP_PATH="C:\\xampp\\mysql\\bin\\mysqldump.exe"
```

Linux/macOS:

```
     MYSQLDUMP_PATH="/usr/bin/mysqldump"
```

You can test the path in terminal:

```
     C:\xampp\mysql\bin\mysqldump.exe --version   # Windows
     /usr/bin/mysqldump --version                  # Linux
```

2️⃣ VPS / Shared Hosting
------------------------

[](#2️⃣-vps--shared-hosting)

On VPS with shell access:

```
     MYSQLDUMP_PATH="/usr/bin/mysqldump"
```

On shared hosting:
------------------

[](#on-shared-hosting)

1. Check if mysqldump is available:

```
     which mysqldump
```

2. Use the full path returned:

```
     MYSQLDUMP_PATH="/usr/local/mysql/bin/mysqldump"
```

Supported modes:
----------------

[](#supported-modes)

php → No CLI, pure PHP

sql → Uses mysqldump

Route
-----

[](#route)

```
     GET /flex/db-dump
```

Protect it:
-----------

[](#protect-it)

```
     Route::middleware(['auth', 'role:admin'])->group(...)
```

Usage
-----

[](#usage)

```
Visit:

```

```
    /flex/db-dump
```

Your database will download automatically.

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

[](#requirements)

PHP 8.1+ Laravel 10+ mysqldump (for sql mode)

Security
--------

[](#security)

⚠️ Always restrict route access (admin only).

🖥 Server Requirements for mysqldump Mode (VPS / VFS)
----------------------------------------------------

[](#-server-requirements-for-mysqldump-mode-vps--vfs)

When using sql mode, flex-db-dump relies on the system-level mysqldump binary. This does NOT work automatically unless your server is properly configured.

✅ Supported Server Types
------------------------

[](#-supported-server-types)

1. VPS (DigitalOcean, AWS EC2, Hetzner, Linode, etc.)
2. Dedicated server
3. Docker-based servers
4. Self-managed cloud servers

⚠️ Not supported on most shared hosting environments.
-----------------------------------------------------

[](#️-not-supported-on-most-shared-hosting-environments)

1️⃣ Verify mysqldump Is Installed
---------------------------------

[](#1️⃣-verify-mysqldump-is-installed)

Run this on your server:

Windows:

```
    mysqldump --version
```

Expected output:

```
    mysqldump  Ver 8.0.30 for Win64 on x86_64 (MySQL Community Server - GPL)
```

MacOS

```
    which mysqldump
```

Expected output:

```
    /usr/bin/mysqldump
```

If nothing is returned, install it.

2️⃣ Install MySQL Client (If Missing)
-------------------------------------

[](#2️⃣-install-mysql-client-if-missing)

Ubuntu / Debian

```
    sudo apt update
    sudo apt install mysql-client -y
```

CentOS / Rocky / Alma

```
    sudo yum install mysql -y
```

3️⃣ Ensure PHP Can Execute System Commands
------------------------------------------

[](#3️⃣-ensure-php-can-execute-system-commands)

The following PHP functions must NOT be disabled:

1. proc\_open
2. shell\_exec
3. exec

Check:

```
    php -i | grep disable_functions
```

If disabled, update php.ini:

```
    disable_functions =
```

Then restart PHP:

```
    sudo systemctl restart php8.2-fpm
```

4️⃣ MySQL Credentials Access (IMPORTANT)
----------------------------------------

[](#4️⃣-mysql-credentials-access-important)

Option A: Use Laravel .env (Default)

```
  DB_HOST=127.0.0.1
  DB_DATABASE=your_db
  DB_USERNAME=your_user
  DB_PASSWORD=your_password
```

⚠️ Some MySQL versions block passwords passed via CLI.

Option B (RECOMMENDED): Use .my.cnf (Most Secure)
-------------------------------------------------

[](#option-b-recommended-use-mycnf-most-secure)

Create this file:

```
  nano ~/.my.cnf
```

Add:

\[mysqldump\]

```
  user=your_db_user
  password=your_db_password
  host=127.0.0.1
```

Set permissions:
----------------

[](#set-permissions)

```
   chmod 600 ~/.my.cnf
```

Then remove password from CLI usage automatically — mysqldump will read it securely.

✅ This avoids password exposure in process lists.

5️⃣ SELinux (CentOS Only)
-------------------------

[](#5️⃣-selinux-centos-only)

If SELinux is enabled:

```
setsebool -P httpd_can_network_connect_db 1
```

6️⃣ Storage Permissions
-----------------------

[](#6️⃣-storage-permissions)

Ensure Laravel can write backups:

```
   chmod -R 775 storage
   chown -R www-data:www-data storage
```

7️⃣ Test mysqldump Manually
---------------------------

[](#7️⃣-test-mysqldump-manually)

Before using the package:

```
   mysqldump your_db > test.sql
```

If this fails, the package will fail too.

8️⃣ Enable SQL Mode in Package
------------------------------

[](#8️⃣-enable-sql-mode-in-package)

```
FLEX_DB_DUMP_MODE=sql

```

9️⃣ When to Use php Mode Instead
--------------------------------

[](#9️⃣-when-to-use-php-mode-instead)

Use PHP exporter mode if:

1. Shared hosting
2. No shell access
3. proc\_open disabled
4. No mysqldump available

```
   FLEX_DB_DUMP_MODE=php
```

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

[](#-security-recommendations)

```
1. Always protect /flex/db-dump route
2. Restrict to admin users only
3. Add rate limiting
4. Never expose publicly

```

Example:
--------

[](#example)

```
  Route::middleware(['auth', 'role:admin', 'throttle:1,10'])->group(function () {
  Route::get('flex/db-dump', [\Flex\DbDump\Http\Controllers\DbDumpController::class, 'download']);
  })->name('flex_db_dump');
```

Author
------

[](#author)

```
Daiyan Mozumder

```

License
-------

[](#license)

```
MIT

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance82

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Total

6

Last Release

92d ago

Major Versions

v1.0.2 → v2.0.02026-02-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/0306cc63f1bc4923a2db180a4874181070fa930957dc8b8b032ec89fb4c4f3b9?d=identicon)[MiltonDaiyan](/maintainers/MiltonDaiyan)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/daiyan-mozumder-flex-db-dump/health.svg)

```
[![Health](https://phpackages.com/badges/daiyan-mozumder-flex-db-dump/health.svg)](https://phpackages.com/packages/daiyan-mozumder-flex-db-dump)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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