PHPackages                             monkeyscloud/monkeyslegion-backup - 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. monkeyscloud/monkeyslegion-backup

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

monkeyscloud/monkeyslegion-backup
=================================

A PHP library and CLI for backing up and restoring databases to local disk, S3, or GCS.

1.0.0(1mo ago)0191—4.8%MITPHPPHP ^8.4CI passing

Since Jul 2Pushed 1mo agoCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Backup)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-backup)[ Docs](https://github.com/monkeyscloud/MonkeysLegion-Backup)[ RSS](/packages/monkeyscloud-monkeyslegion-backup/feed)WikiDiscussions main Synced 1w ago

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

MonkeysLegion Backup
====================

[](#monkeyslegion-backup)

A PHP library and CLI for backing up and restoring databases to local disk, Amazon S3, or Google Cloud Storage.

Built for PHP 8.4+, framework-agnostic, and designed to wrap the native database tools you already trust (`mysqldump`, `pg_dump`, `mongodump`, `redis-cli`, etc.) behind a consistent API and command-line interface.

Features
--------

[](#features)

- **Database engines** — MySQL, PostgreSQL, MongoDB, Redis, SQLite
- **Storage backends** — local filesystem, S3 (including MinIO), Google Cloud Storage
- **Compression** — optional gzip with checksum metadata sidecars
- **CLI commands** — `backup:dump`, `backup:restore`, `backup:list`, `backup:engines`, `backup:install`
- **Extensible** — register custom engines and storage adapters via the DI container

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

[](#requirements)

- PHP 8.4+
- Native CLI tools for the engines you use (e.g. `mysqldump`, `pg_dump`, `mongodump`, `redis-cli`)
- Optional: AWS SDK / Google Cloud Storage PHP client (included via Composer for S3/GCS adapters)

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

[](#installation)

```
composer require monkeyscloud/monkeyslegion-backup
```

Publish the configuration file into your application:

```
php ml backup:install
# or: php ml backup:install --format=php
```

> **Note:** The `php ml backup:*` commands work out of the box in MonkeysLegion-Skeleton. In other applications, register the commands manually by composing `monkeyscloud/monkeyslegion-cli` and `monkeyscloud/monkeyslegion-di`.

See [docs/registration\_guide.md](docs/registration_guide.md) for DI container setup.

Quick start
-----------

[](#quick-start)

Dump a MySQL database to local storage:

```
php ml backup:dump \
  --engine=mysql \
  --database=myapp \
  --host=127.0.0.1 \
  --user=root \
  --password=secret \
  --compress
```

Restore from a stored backup:

```
php ml backup:restore \
  --engine=mysql \
  --database=myapp \
  --key=backups/myapp_20260702_120000.sql.gz
```

List available engines and stored backups:

```
php ml backup:engines
php ml backup:list
```

Credentials can also be read from environment variables (e.g. `MYSQL_HOST`, `MYSQL_USER`, `MYSQL_PASSWORD`). See [.env.example](.env.example).

Supported engines
-----------------

[](#supported-engines)

EngineDump toolRestore toolNotesMySQL`mysqldump``mysql`Compression supportedPostgreSQL`pg_dump``psql` / `pg_restore`Plain and custom (`-Fc`) formatsMongoDB`mongodump``mongorestore`Archive formatRedis`redis-cli --rdb`RDB file copyRestore replaces `dump.rdb`SQLitefile copyfile copyFile or in-memory via PDOStorage adapters
----------------

[](#storage-adapters)

DriverUse case`local`Filesystem storage under a configurable root`s3`AWS S3 or S3-compatible endpoints (MinIO)`gcs`Google Cloud StorageConfigure drivers in `config/backup.mlc` or `config/backup.php`.

Library usage
-------------

[](#library-usage)

```
use MonkeysLegion\Backup\Engine\EngineRegistry;
use MonkeysLegion\Backup\Runner\BackupRunner;
use MonkeysLegion\Backup\ValueObject\DumpOptions;

$registry = EngineRegistry::default();
$runner   = new BackupRunner($registry, $storage, $compressor);

$result = $runner->run(new DumpOptions(
    engine: 'mysql',
    host: '127.0.0.1',
    user: 'root',
    password: 'secret',
    database: 'myapp',
    compress: true,
), 'backups/myapp.sql.gz');
```

Testing
-------

[](#testing)

Unit tests run without external services:

```
composer test
```

Integration tests use Docker Compose for live databases and cloud emulators:

```
docker compose -f docker-compose.testing.yml up -d --wait
cp .env.testing .env
composer test:all
```

Other useful scripts:

```
composer test:db           # database engine integration tests
composer test:integration  # gcs, s3, and db groups
composer stan              # PHPStan level 8
composer ci                # stan + full test suite
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2913369?v=4)[Jorge Peraza](/maintainers/yorchperaza)[@yorchperaza](https://github.com/yorchperaza)

---

Top Contributors

[![Amanar-Marouane](https://avatars.githubusercontent.com/u/155680356?v=4)](https://github.com/Amanar-Marouane "Amanar-Marouane (30 commits)")

---

Tags

clis3databasebackupmysqlsqlitepostgresredisgcsmongodbrestore

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/monkeyscloud-monkeyslegion-backup/health.svg)

```
[![Health](https://phpackages.com/badges/monkeyscloud-monkeyslegion-backup/health.svg)](https://phpackages.com/packages/monkeyscloud-monkeyslegion-backup)
```

###  Alternatives

[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114550.1k6](/packages/apix-cache)[rybakit/phive-queue

$queue-&gt;push('I can be popped off after', '10 minutes');

16442.0k1](/packages/rybakit-phive-queue)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

62416.0k12](/packages/rah-danpu)

PHPackages © 2026

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