PHPackages                             dcblogdev/laravel-db-sync - 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. dcblogdev/laravel-db-sync

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

dcblogdev/laravel-db-sync
=========================

Sync database down.

v1.1.9(2mo ago)35038.3k↓41.9%34PHPCI passing

Since Jun 23Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/dcblogdev/laravel-db-sync)[ Packagist](https://packagist.org/packages/dcblogdev/laravel-db-sync)[ GitHub Sponsors](https://github.com/dcblogdev)[ RSS](/packages/dcblogdev-laravel-db-sync/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (18)Used By (0)

Community
---------

[](#community)

There is a Discord community.  For quick help, ask questions in the appropriate channel.

Laravel DB Sync
===============

[](#laravel-db-sync)

[![DB Dync](https://repository-images.githubusercontent.com/506690782/a5b01352-4869-4e6d-8e46-d44e93c960df)](https://repository-images.githubusercontent.com/506690782/a5b01352-4869-4e6d-8e46-d44e93c960df)

Introduction
------------

[](#introduction)

Sync remote database to a local database

> A word of warning you should only sync a remote database into a local database if you have permission to do so within your organisation's policies. I'm syncing during early phases of development where the data is largely test data and not actual customer data.

Connection can be made over SSH or using a remote MySQL connection.

Install
-------

[](#install)

Install the package.

```
composer require dcblogdev/laravel-db-sync
```

Config
------

[](#config)

You can publish the config file with:

```
php artisan vendor:publish --provider="Dcblogdev\DbSync\DbSyncServiceProvider" --tag="config"

```

**Note:** If you're updating from an earlier version, republish the config to get the new anonymization options:

```
php artisan vendor:publish --provider="Dcblogdev\DbSync\DbSyncServiceProvider" --tag="config" --force

```

.env
----

[](#env)

Set the remote database credentials in your .env file

When using SSH Add:

```
REMOTE_USE_SSH=true
REMOTE_SSH_PORT=22
REMOTE_SSH_USERNAME=
REMOTE_DATABASE_HOST=

REMOTE_DATABASE_USERNAME=
REMOTE_DATABASE_PORT=3306
REMOTE_DATABASE_NAME=
REMOTE_DATABASE_PASSWORD=
REMOTE_DATABASE_IGNORE_TABLES=''

REMOTE_REMOVE_FILE_AFTER_IMPORT=true
REMOTE_IMPORT_FILE=true

```

For only MySQL remote connections:

```
REMOTE_DATABASE_HOST=
REMOTE_DATABASE_USERNAME=
REMOTE_DATABASE_PORT=3306
REMOTE_DATABASE_NAME=
REMOTE_DATABASE_PASSWORD=
REMOTE_DATABASE_IGNORE_TABLES=''

REMOTE_REMOVE_FILE_AFTER_IMPORT=true
REMOTE_IMPORT_FILE=true

```

Set a comma seperate list of tables NOT to export in `REMOTE_DATABASE_IGNORE_TABLES`

To generate a SQL with a custom file name `REMOTE_DEFAULT_FILE_NAME`

To specify a different local database connection:

```
LOCAL_TARGET_CONNECTION=different_mysql_connection

```

Set the mysql command path:

```
LOCAL_MYSQL_PATH=/usr/bin/mysql

```

For only mysqldump:

```
REMOTE_MYSQLDUMP_SKIP_TZ_UTC=true

```

Usage
-----

[](#usage)

To export a remote database to OVERRIDE your local database by running:

```
php artisan db:production-sync
```

Provide a filename for export on the fly by passing the option --filename, remember to provide .sql

```
php artisan db:production-sync --filename=other.sql
```

Run the command without attempting to export:

```
php artisan db:production-sync --test
```

Sync only specific tables by passing a comma-separated list with `--tables`:

```
php artisan db:production-sync --tables=users,orders,products
```

When `--tables` is used, the `REMOTE_DATABASE_IGNORE_TABLES` list is bypassed — only the specified tables are exported.

Anonymizing Data
----------------

[](#anonymizing-data)

You can anonymize sensitive data after syncing by using the `--anonymize` or `-A` flag. This is **opt-in only** and disabled by default.

### Configuration

[](#configuration)

First, define which tables and columns should be anonymized in `config/dbsync.php`:

```
'anonymize' => [
    'users' => [
        'email' => 'safeEmail',
        'name' => 'name',
        'phone' => 'phoneNumber',
        'password' => 'bcrypt:password',
    ],
    'customers' => [
        'email' => 'safeEmail',
        'first_name' => 'firstName',
        'last_name' => 'lastName',
        'address' => 'address',
    ],
],
```

The values use [Faker](https://fakerphp.github.io/) methods. Special prefix `bcrypt:` will hash the generated value.

### Usage

[](#usage-1)

```
php artisan db:production-sync --anonymize
```

Or use the shorthand:

```
php artisan db:production-sync -A
```

The anonymization runs **after** the database import is complete. Each configured table will be processed with a progress indicator.

**Important:** Only use anonymization when syncing to local/staging environments and ensure you have permission to sync production data within your organization's policies.

Aliases
-------

[](#aliases)

There are shortcuts that can be used:

`-T` = will use `--test``-F` = will use `--filename``-A` = will use `--anonymize`

Alternative name
----------------

[](#alternative-name)

When connecting to a none production database, say a staging database you can choose to use this alternative name:

`db:remote-sync` may be used instead of `db:production-sync`

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.2% 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 ~91 days

Recently: every ~183 days

Total

16

Last Release

63d ago

### Community

Maintainers

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

---

Top Contributors

[![dcblogdev](https://avatars.githubusercontent.com/u/1018170?v=4)](https://github.com/dcblogdev "dcblogdev (61 commits)")[![Zaryabakhtar](https://avatars.githubusercontent.com/u/42775803?v=4)](https://github.com/Zaryabakhtar "Zaryabakhtar (6 commits)")[![thursdaydan](https://avatars.githubusercontent.com/u/8914312?v=4)](https://github.com/thursdaydan "thursdaydan (3 commits)")[![m-popa](https://avatars.githubusercontent.com/u/23634938?v=4)](https://github.com/m-popa "m-popa (1 commits)")[![racibaz](https://avatars.githubusercontent.com/u/1975129?v=4)](https://github.com/racibaz "racibaz (1 commits)")[![vesper8](https://avatars.githubusercontent.com/u/816028?v=4)](https://github.com/vesper8 "vesper8 (1 commits)")[![Witti](https://avatars.githubusercontent.com/u/80333?v=4)](https://github.com/Witti "Witti (1 commits)")[![xfolder](https://avatars.githubusercontent.com/u/13942856?v=4)](https://github.com/xfolder "xfolder (1 commits)")[![Aleksandar-Mitic](https://avatars.githubusercontent.com/u/10186898?v=4)](https://github.com/Aleksandar-Mitic "Aleksandar-Mitic (1 commits)")[![zmeeeeeva](https://avatars.githubusercontent.com/u/13080665?v=4)](https://github.com/zmeeeeeva "zmeeeeeva (1 commits)")[![davidbirkin](https://avatars.githubusercontent.com/u/34802973?v=4)](https://github.com/davidbirkin "davidbirkin (1 commits)")[![imsus](https://avatars.githubusercontent.com/u/1058471?v=4)](https://github.com/imsus "imsus (1 commits)")

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dcblogdev-laravel-db-sync/health.svg)

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

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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