PHPackages                             xslain/database-backup-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. xslain/database-backup-sync

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

xslain/database-backup-sync
===========================

Automated 24-hour database backups with multi-cloud upload (S3, Google Drive, OneDrive, local), AES-256-GCM/GPG encryption, retention, integrity verification, and observability for Laravel.

1.0.2(yesterday)03↑1900%MITPHPPHP ^8.1CI failing

Since Aug 16Pushed yesterdayCompare

[ Source](https://github.com/ogoungaemmanuel/databasebackupsync)[ Packagist](https://packagist.org/packages/xslain/database-backup-sync)[ RSS](/packages/xslain-database-backup-sync/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (17)Versions (4)Used By (0)

Database Backup Sync
====================

[](#database-backup-sync)

Automated 24-hour database backups with multi-cloud upload (S3, Google Drive, OneDrive, local), AES-256-GCM / GPG encryption, retention policies, integrity verification, and observability for Laravel.

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](composer.json)[![Laravel](https://camo.githubusercontent.com/7eac27003ae0765558d87065fa00079eac395fdddb669328473b0e873e4b6261/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d382e38332532302537432532303925323025374325323031302532302537432532303131253230253743253230313225323025374325323031332d726564)](composer.json)

---

Features
--------

[](#features)

- **Multi-database support** — MySQL, PostgreSQL, SQLite, SQL Server.
- **Native binary dumpers** (`mysqldump`, `pg_dump`, `sqlite3`, `sqlcmd`) with a **PDO streaming fallback** for hosts without shell access.
- **Multi-cloud upload** — S3 (multipart + resumable), Google Drive, OneDrive, and local disk. Uploads to each driver are independent — one failing driver never loses the backup.
- **Encryption at rest** — streaming **AES-256-GCM** (authenticated) built in, optional **GPG** (symmetric or recipient).
- **Retention policies** — prune by age, count, or total size (policies are ANDed).
- **Integrity verification** — SHA-256 checksums and a JSON manifest stored alongside every backup.
- **Scheduling** — registers `db:backup` with Laravel's scheduler (default: daily at 02:00), with `onOneServer` and `withoutOverlapping` support.
- **Queued execution** — run the whole pipeline (or just uploads) as queued jobs with exponential backoff.
- **Notifications** — Slack webhook, email, and generic webhook (HMAC-SHA256 signed) on success/failure.
- **Observability** — run history table, in-memory metrics, and an optional token-protected JSON status endpoint.
- **Restore** — download, decrypt, and restore a backup into any configured connection.

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

[](#requirements)

- PHP **^8.1**
- Laravel **8.83 – 13** (illuminate components)
- Extensions: `json`, `openssl`, `pdo`
- `guzzlehttp/guzzle` (bundled dependency)
- **Optional:** `aws/aws-sdk-php` (S3 driver), `ext-gnupg` or the `gpg` binary (GPG encryption)

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

[](#installation)

```
composer require xslain/database-backup-sync
```

Publish the configuration (and optionally the migration for run history):

```
php artisan vendor:publish --tag=database-backup-config
php artisan vendor:publish --tag=database-backup-migrations
php artisan migrate
```

> The migration is optional — run history and the status endpoint's `recent_runs` only work when the `database_backup_runs` table exists.

### Quick start

[](#quick-start)

Set the minimum environment variables, then run a backup:

```
DB_BACKUP_DRIVER=local
DB_BACKUP_ENCRYPT=true
DB_BACKUP_KEY=base64:your-32-byte-key-here
```

```
# Verify driver connectivity with a probe upload
php artisan db:backup:test

# Take a backup and upload it
php artisan db:backup

# List stored backups
php artisan db:backup:list
```

Generate an encryption key with:

```
php -r "echo base64_encode(random_bytes(32));"
```

Commands
--------

[](#commands)

CommandDescription`php artisan db:backup`Dump → compress → encrypt → upload → record → prune`php artisan db:backup:prune`Apply the retention policy and delete expired backups`php artisan db:backup:list`List stored backups across drivers`php artisan db:backup:restore {file}`Download, decrypt, and restore a backup`php artisan db:backup:test`Verify connectivity to each driver with a probe uploadScheduling
----------

[](#scheduling)

The package registers `db:backup` with Laravel's scheduler automatically. Add the scheduler to your system cron (once per minute):

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

Defaults (all configurable):

- Runs **daily at 02:00** (`0 2 * * *`)
- `onOneServer` — only one server runs the backup when using a shared cache
- `withoutOverlapping` — never run two backups at once

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

[](#configuration)

All configuration lives in `config/database-backup.php` (published) and is driven by environment variables. Highlights:

AreaEnv varsDefault driver`DB_BACKUP_DRIVER`S3`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`, `DB_BACKUP_S3_BUCKET`, `DB_BACKUP_S3_PREFIX`Google Drive`DB_BACKUP_DRIVE_AUTH`, `DB_BACKUP_DRIVE_SERVICE_ACCOUNT_JSON`, `DB_BACKUP_DRIVE_FOLDER_ID`OneDrive`DB_BACKUP_ONEDRIVE_TENANT_ID`, `DB_BACKUP_ONEDRIVE_CLIENT_ID`, `DB_BACKUP_ONEDRIVE_CLIENT_SECRET`, `DB_BACKUP_ONEDRIVE_GRANT`Encryption`DB_BACKUP_ENCRYPT`, `DB_BACKUP_KEY`, `DB_BACKUP_GPG`, `DB_BACKUP_GPG_RECIPIENTS`Retention`DB_BACKUP_RETENTION_DAYS`, `DB_BACKUP_RETENTION_COUNT`, `DB_BACKUP_RETENTION_MAX_SIZE`Scheduling`DB_BACKUP_SCHEDULE_EXPRESSION`, `DB_BACKUP_SCHEDULE_TIMEZONE`Notifications`DB_BACKUP_SLACK_WEBHOOK_URL`, `DB_BACKUP_EMAIL_TO`, `DB_BACKUP_WEBHOOK_URL`, `DB_BACKUP_WEBHOOK_SECRET`Queue`DB_BACKUP_QUEUE`, `DB_BACKUP_QUEUE_TRIES`Status endpoint`DB_BACKUP_STATUS_ENABLED`, `DB_BACKUP_STATUS_TOKEN`See **[docs/CONFIGURATION.md](docs/CONFIGURATION.md)** for the complete reference.

Programmatic usage
------------------

[](#programmatic-usage)

```
use DatabaseBackupSync\Facades\DatabaseBackup;

// Run a backup to the default driver(s)
$result = DatabaseBackup::backup(['label' => 'pre-deploy']);

// Backup to specific drivers, encrypted
$result = DatabaseBackup::backup([
    'drivers' => ['s3', 'google_drive'],
    'encrypt' => true,
    'label'   => 'nightly',
]);

// Apply retention pruning
DatabaseBackup::prune();

// List backups
$backups = DatabaseBackup::listBackups('s3');

// Restore a backup
DatabaseBackup::restore('backup_2026-08-16_02-00-00.sql.gz.enc', [
    'driver'     => 's3',
    'connection' => 'mysql',
    'decrypt'    => true,
]);

// Test driver connectivity
DatabaseBackup::testDrivers();
```

Status endpoint
---------------

[](#status-endpoint)

When enabled, a token-protected JSON endpoint reports the last run, recent runs, storage usage, and metrics:

```
DB_BACKUP_STATUS_ENABLED=true
DB_BACKUP_STATUS_TOKEN=your-secret-token
```

```
curl -H "X-Backup-Token: your-secret-token" https://your-app.com/database-backup/status
```

Events
------

[](#events)

Listen to these events to build your own integrations:

EventFired when`BackupStarted`A backup run begins`BackupCompleted`A backup finished and was uploaded`BackupFailed`A backup run failed`BackupUploaded`A file was uploaded to one driver`BackupUploadFailed`An upload to one driver failed`BackupPruned`Retention pruning deleted files`StorageUsageAlert`A driver's usage exceeded the configured thresholdDocumentation
-------------

[](#documentation)

- [Installation &amp; packages](docs/INSTALLATION.md)
- [Configuration reference](docs/CONFIGURATION.md)
- [Drivers (S3, Google Drive, OneDrive, local)](docs/DRIVERS.md)
- [Usage: commands &amp; API](docs/USAGE.md)
- [Deployment guide](docs/DEPLOYMENT.md)
- [Security &amp; encryption](docs/SECURITY.md)

Testing
-------

[](#testing)

```
composer test            # full suite
composer test:unit       # unit tests only
composer test:integration
composer test:feature
composer lint            # PHP lint on the Manager
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

Built by [Xslain Innovations Limited](https://www.xslain.com).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

3

Last Release

1d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravels3encryptiondatabasebackupmysqlsqlitepostgresqlsqlserverOneDrivegoogle-driveretention

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xslain-database-backup-sync/health.svg)

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k31.8M160](/packages/laravel-cashier)[aedart/athenaeum

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

265.2k](/packages/aedart-athenaeum)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9922.4M146](/packages/roots-acorn)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M188](/packages/spatie-laravel-health)

PHPackages © 2026

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