PHPackages                             ajaxray/laravel-server-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. ajaxray/laravel-server-sync

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

ajaxray/laravel-server-sync
===========================

A Laravel package to easily sync your production database and files to your local environment

v1.2.0(11mo ago)622612MITPHPPHP ^8.1

Since Mar 7Pushed 11mo ago3 watchersCompare

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

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

Laravel Server Sync
===================

[](#laravel-server-sync)

[![Latest Version on Packagist](https://camo.githubusercontent.com/035cbb2395132db35e2a2e24f10895a83ab26078c72054461cc63f03f6e5d84e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616a61787261792f6c61726176656c2d7365727665722d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ajaxray/laravel-server-sync)[![Total Downloads](https://camo.githubusercontent.com/2f01a25e8abd04eaeddf78933a2e9e79d2d7a9c83150c1a2c948d26d19a46d0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616a61787261792f6c61726176656c2d7365727665722d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ajaxray/laravel-server-sync)[![License](https://camo.githubusercontent.com/c3a66ed2c22e5baf824f72d97d8194a6ff53ca8c1fcae51f3cd172b805799d05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616a61787261792f6c61726176656c2d7365727665722d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ajaxray/laravel-server-sync)

A Laravel package to easily sync your production/staging database and storage files to your local environment. Perfect for debugging production issues or keeping your local environment up to date with production data.

> **Note**: This package is now stable and ready for production use. It supports Laravel 10.x and 11.x.

[![Laravel Server Sync Banner](/arts/laravel_server_sync_banner.jpg)](/arts/laravel_server_sync_banner.jpg)

Features
--------

[](#features)

- 🔄 One-command sync of both database and files
- 🔒 Secure SSH-based file transfer
- 📁 Smart file syncing with rsync
- 🗄️ Database dump and restore
- ⚡ Progress indicators for long operations
- 🛠️ Highly configurable

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- SSH access to production server
- MySQL/MariaDB client installed locally
- rsync installed on both local and production servers

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

[](#installation)

```
composer require ajaxray/laravel-server-sync
```

To install for dev environments

```
composer require --dev ajaxray/laravel-server-sync
```

After installation, publish the configuration file:

```
php artisan vendor:publish --provider="Ajaxray\ServerSync\ServerSyncServiceProvider"
```

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

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
PROD_SSH_HOST=your-production-server.com
PROD_SSH_USER=your-ssh-username
PROD_SSH_PATH=/path/to/laravel
PROD_SSH_KEY=/path/to/your/private/key
```

### Configuration File

[](#configuration-file)

The published config file `config/server-sync.php` allows you to:

- Configure default server settings
- Exclude specific tables from database sync
- Configure file sync paths and exclusions
- Customize dump location

### SSH Key Authentication

[](#ssh-key-authentication)

For enhanced security, you can specify SSH private key files for authentication:

**Via Environment Variables:**

```
PROD_SSH_KEY=/home/user/.ssh/production_key
STAGING_SSH_KEY=/home/user/.ssh/staging_key
```

**Via Command Line:**

```
php artisan sync:pull --key=/path/to/private/key
```

**Via Configuration File:**

```
'production' => [
    'host' => 'prod.example.com',
    'user' => 'deploy',
    'path' => '/var/www/app',
    'key' => '/home/user/.ssh/production_key',
],
```

> **Note**: Ensure your private key file has proper permissions (600) and that the corresponding public key is added to the server's `~/.ssh/authorized_keys` file.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Sync both database and files:

```
php artisan sync:pull
```

### Database Sync Options

[](#database-sync-options)

```
# Skip database sync entirely
php artisan sync:pull --skip-db

# Exclude specific tables
php artisan sync:pull --exclude-tables=logs,cache,sessions

# Only sync specific tables
php artisan sync:pull --only-tables=users,products,orders
```

### File Sync Options

[](#file-sync-options)

```
# Skip file sync entirely
php artisan sync:pull --skip-files

# Sync files with deletion (removes local files that don't exist in production)
php artisan sync:pull --delete
```

### Server Configuration Options

[](#server-configuration-options)

By default, it'll take host, user, path etc. from the production server definition in config file.

Also we can specify which remote server definition to use (see config file), if we have defined multiple servers. If any config is specified as inline option, it'll get precidence over config values.

```
php artisan sync:pull --remote=staging

# Override server details inline
php artisan sync:pull --host=prod.example.com --user=deploy --path=/var/www/app

# Specify SSH key file for authentication
php artisan sync:pull --key=/path/to/private/key

# All options can be specified inline to overwrite config values
php artisan sync:pull --host=prod.example.com --user=deploy --key=~/.ssh/production_key --exclude-tables=logs,migrations
```

### Safety Features

[](#safety-features)

```
# Force sync in production environment (use with caution!)
php artisan sync:pull --force
```

> **Note**: The `--force` option should be used with extreme caution as it overrides the production environment safety check.

Security
--------

[](#security)

- Uses SSH for secure file transfer
- Supports SSH key-based authentication (recommended)
- Can specify custom SSH private key files via `--key` option or configuration
- Temporary files are automatically cleaned up
- Database credentials are never stored locally

Troubleshooting
---------------

[](#troubleshooting)

### SSH Connection Issues

[](#ssh-connection-issues)

- Verify SSH key-based authentication is set up
- Check if you can manually SSH into the server using the key: `ssh -i /path/to/key user@host`
- Ensure proper permissions for the SSH user and private key file (600 for key file)
- Use `--key` option or configure SSH key path in config file if using custom key location

### Database Sync Issues

[](#database-sync-issues)

- Verify MySQL client installation
- Check database credentials in both environments
- Ensure sufficient privileges for database operations

### File Sync Issues

[](#file-sync-issues)

- Verify rsync installation
- Check storage directory permissions
- Use stable internet connection for large files

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Anis Uddin Ahmad](https://github.com/ajaxray)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance51

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

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

Total

4

Last Release

340d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d53da7c0bace1db3c303d2c105fdf270d5fad970432c6dd702d9e23ea62ab86?d=identicon)[ajaxray](/maintainers/ajaxray)

---

Top Contributors

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

---

Tags

laraveldatabasefilessyncdeploymentproduction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ajaxray-laravel-server-sync/health.svg)

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

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[clickbar/laravel-magellan

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

423715.4k1](/packages/clickbar-laravel-magellan)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[eighty8/laravel-seeder

Versioned, environment-based Seeders in Laravel

1857.1k](/packages/eighty8-laravel-seeder)

PHPackages © 2026

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