PHPackages                             xve/laravel-db-export - 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. xve/laravel-db-export

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

xve/laravel-db-export
=====================

Laravel database export package with profile-based exclusions, anonymization, and zero-impact exports

v1.2.6(2mo ago)0248↓50%1[3 PRs](https://github.com/XVE-BV/laravel-db-export/pulls)MITPHPPHP ^8.2CI passing

Since Feb 5Pushed 2mo agoCompare

[ Source](https://github.com/XVE-BV/laravel-db-export)[ Packagist](https://packagist.org/packages/xve/laravel-db-export)[ RSS](/packages/xve-laravel-db-export/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (14)Used By (0)

Laravel DB Export
=================

[](#laravel-db-export)

A Laravel package for database exports with profile-based exclusions, anonymization, and zero-impact exports.

Features
--------

[](#features)

- **Profile-based exports** - Predefined configurations for different use cases
- **Zero-impact exports** - Uses `--single-transaction` and `--quick` for minimal database load
- **Compression** - Automatic gzip compression with streaming for large databases
- **Size estimation** - Pre-flight disk space validation
- **Structure-only tables** - Export schema without data for large tables
- **Anonymization** - Mask or fake sensitive data (PII)
- **Cleanup** - Automatically remove old exports

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

[](#installation)

```
composer require xve/laravel-db-export
```

Publish the configuration:

```
php artisan vendor:publish --tag=db-export-config
```

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

[](#configuration)

### MySQL/MariaDB Binary Path

[](#mysqlmariadb-binary-path)

If `mysqldump` is not in your PATH, set it in `config/db-export.php` or `.env`:

```
'mysql_options' => [
    'dump_binary_path' => env('DB_EXPORT_DUMP_BINARY_PATH'),
    // ...
],
```

```
DB_EXPORT_DUMP_BINARY_PATH=/usr/local/mysql/bin
# or for Herd/MariaDB:
DB_EXPORT_DUMP_BINARY_PATH=/Users/Shared/Herd/services/mariadb/10.11.6/bin
```

### MariaDB Compatibility

[](#mariadb-compatibility)

For MariaDB, ensure MySQL-specific options are disabled:

```
'mysql_options' => [
    'set_gtid_purged' => null,      // MySQL-only
    'column_statistics' => null,     // MySQL 8+ only
],
```

### Cleanup Old Exports

[](#cleanup-old-exports)

Automatically delete old exports before creating new ones:

```
'cleanup' => [
    'enabled' => true,
    'keep_recent' => 0,  // 0 = delete all, or set number to keep
],
```

Commands
--------

[](#commands)

### Setup / Find mysqldump

[](#setup--find-mysqldump)

Find the mysqldump binary and get configuration instructions:

```
php artisan db:export:setup
```

This command searches common locations for `mysqldump` and displays:

- Found binary paths with versions
- Configuration instructions for `.env` or `config/db-export.php`
- Current configuration status

### List Profiles

[](#list-profiles)

```
php artisan db:export:list-profiles
php artisan db:export:list-profiles --detailed
```

### Estimate Export Size

[](#estimate-export-size)

```
php artisan db:export:estimate
php artisan db:export:estimate --detailed
```

### Export Database

[](#export-database)

```
# Export with default profile
php artisan db:export

# Skip confirmation prompt
php artisan db:export --force

# Dry run (show what would be exported)
php artisan db:export --dry-run

# Export only telescope/audits for debugging
php artisan db:export --profile=inspection
```

### Prune Exports

[](#prune-exports)

Delete all export files:

```
php artisan db:export:prune
```

Export Profiles
---------------

[](#export-profiles)

ProfileDescription`default`Clean export with structure-only for logs/cache/sessions and anonymized PII`inspection`Only telescope and audits (for debugging)Command Options
---------------

[](#command-options)

### Table Selection

[](#table-selection)

```
# Exclude specific tables
--exclude=large_table --exclude=another_table

# Only include specific tables
--include-only=users --include-only=orders

# Export structure only (no data)
--structure-only=audits --structure-only=logs

# Override structure-only (include data)
--include-data=audits
```

### Output Options

[](#output-options)

```
# Custom output path
--path=/backups/db

# Custom filename
--filename=backup_2024.sql.gz

# Disable compression
--no-compress

# Use different database connection
--connection=mysql_replica
```

### Other Options

[](#other-options)

```
# Exclude views
--no-views

# Disable foreign key wrapper
--no-fk-wrapper

# Dry run
--dry-run

# Skip confirmation
--force
```

Examples
--------

[](#examples)

### Standard Export

[](#standard-export)

```
php artisan db:export --force
```

Exports everything with structure-only for logs/cache/sessions and anonymized PII.

### Include Audit Data

[](#include-audit-data)

```
php artisan db:export --include-data=audits --force
```

Override structure-only to include audit data.

### Debug Export

[](#debug-export)

```
php artisan db:export --profile=inspection --force
```

Exports only telescope and audit tables for debugging.

### Specific Tables

[](#specific-tables)

Export only the tables you need — no profile required:

```
# Single table
php artisan db:export --include-only=users --force

# Multiple tables
php artisan db:export --include-only=bunkering --include-only=klant --include-only=facturen --force
```

### Structure Only (No Data)

[](#structure-only-no-data)

```
php artisan db:export --structure-only="*" --force
```

Profiles Configuration
----------------------

[](#profiles-configuration)

Define custom profiles in `config/db-export.php`:

```
'profiles' => [
    'my-profile' => [
        'description' => 'My custom export profile',
        'exclude' => [
            'telescope_*',
            '*_logs',
        ],
        'structure_only' => [
            'audits',
            'activity_log',
        ],
        'include_only' => null,  // null = all tables
        'anonymize' => [
            'users' => [
                'email' => ['strategy' => 'faker', 'method' => 'safeEmail'],
                'password' => ['strategy' => 'hash', 'value' => 'password'],
            ],
        ],
    ],
],
```

Anonymization Strategies
------------------------

[](#anonymization-strategies)

Anonymization works with or without `fakerphp/faker`. If faker is installed, you get realistic fake data. Without it, simple fallbacks are used (e.g., `User_a1b2c3d4`, `user_a1b2c3d4@example.com`).

```
# Optional: Install faker for realistic fake data
composer require fakerphp/faker
```

```
'anonymize' => [
    'users' => [
        // Faker - generate fake data (or fallback if faker not installed)
        'name' => ['strategy' => 'faker', 'method' => 'name'],
        'email' => ['strategy' => 'faker', 'method' => 'safeEmail'],
        'phone' => ['strategy' => 'faker', 'method' => 'phoneNumber'],

        // Hash - bcrypt hash a value
        'password' => ['strategy' => 'hash', 'value' => 'password'],

        // Mask - partially hide value
        'credit_card' => ['strategy' => 'mask', 'keep_last' => 4],

        // Null - set to null
        'remember_token' => ['strategy' => 'null'],

        // Fixed - set to specific value
        'status' => ['strategy' => 'fixed', 'value' => 'active'],
    ],
],
```

### Preserve Admin/Developer Accounts

[](#preserve-admindeveloper-accounts)

Skip anonymization for rows where specific columns match certain email domains:

```
// config/db-export.php
'preserve_rows' => [
    'users' => [
        'column' => 'email',
        'domains' => ['xve.be', 'company.com'],
    ],
    'customers' => [
        'column' => 'contact_email',
        'domains' => ['xve.be'],
    ],
],
```

Users with `@xve.be` or `@company.com` emails will keep their original data while all other users are anonymized. Each table can specify which column to check.

Production Usage
----------------

[](#production-usage)

### Zero-Impact Exports

[](#zero-impact-exports)

**The Problem:** Traditional `mysqldump` commands can severely impact production databases:

- Table locks block all writes during export
- Large result sets consume server memory
- Long-running exports cause timeouts and slow queries

**The Solution:** This package uses mysqldump options that eliminate these issues:

OptionProblem Solved`--single-transaction`Creates a consistent snapshot using InnoDB's MVCC. No table locks, writes continue normally.`--quick`Streams rows directly to output instead of buffering in memory. Handles multi-GB tables without memory issues.`--skip-lock-tables`Prevents `LOCK TABLES` command that would block all writes.With these options, you can safely export a production database while the application continues serving requests with no degradation.

### Best Practices

[](#best-practices)

1. **Use a read replica** for exports when possible:

    ```
    php artisan db:export --connection=replica
    ```
2. **Schedule during low-traffic hours**
3. **Use structure-only** for large tables like audits:

    ```
    'structure_only' => ['audits', 'activity_log'],
    ```
4. **Monitor during export**:

    ```
    watch -n1 "mysql -e \"SHOW GLOBAL STATUS LIKE 'Threads_running';\""
    ```

Output Location
---------------

[](#output-location)

Default: `storage/app/db-exports/`

Files are named: `{database}_{date}_{time}_{profile}.sql.gz`

Example: `my_app_2026-01-15_14h30_default.sql.gz`

See Also
--------

[](#see-also)

- [Package Comparison](docs/comparison.md) - SWOT analysis vs other Laravel backup packages

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance86

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~2 days

Total

10

Last Release

83d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18227129?v=4)[xve](/maintainers/xve)[@xve](https://github.com/xve)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![jonasvanderhaegen-xve](https://avatars.githubusercontent.com/u/216873699?v=4)](https://github.com/jonasvanderhaegen-xve "jonasvanderhaegen-xve (4 commits)")

---

Tags

laraveldatabaseexportdumpmysqlanonymization

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/xve-laravel-db-export/health.svg)

```
[![Health](https://phpackages.com/badges/xve-laravel-db-export/health.svg)](https://phpackages.com/packages/xve-laravel-db-export)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

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