PHPackages                             lily-labs/db-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. [File &amp; Storage](/categories/file-storage)
4. /
5. lily-labs/db-backup

ActiveLibrary[File &amp; Storage](/categories/file-storage)

lily-labs/db-backup
===================

DBBackup it's a library that provides classes to execute mysqldump to backup the given database, relocate the backup file in the local filesystem and compress the resulting backup file.

v0.2.2(2y ago)042MITPHPPHP ^7.1

Since Aug 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Geckomind/DBBackup)[ Packagist](https://packagist.org/packages/lily-labs/db-backup)[ Docs](https://github.com/spatie/DBBackup)[ RSS](/packages/lily-labs-db-backup/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (5)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/808725baeed9bf947459faac6eb0d3c1d0711eca3de869791d030c811a98fc34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c696c792d6c6162732f64622d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lily-labs/db-backup)[![Build Status](https://camo.githubusercontent.com/ada7100d1eab6f52de54af55b969e6ba7c073995e45beb0cfd6bb76bae24f105/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4765636b6f6d696e642f44424261636b75702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Geckomind/DBBackup)[![Quality Score](https://camo.githubusercontent.com/e2e93981aff552e8f196758f3d3c8686d2e799ad6de37844450698160b6ef427/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4765636b6f6d696e642f44424261636b75702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Geckomind/DBBackup)[![Total Downloads](https://camo.githubusercontent.com/bcc3cfe95bacad8923ca4641d8187f9fcd08a5cb4f52279d436382ac7b506320/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c696c792d6c6162732f64622d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lily-labs/db-backup)

DBBackup it's a library that provides classes to execute mysqldump to backup the given database, relocate the backup file in the local filesystem and compress the resulting backup file.

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

[](#requirements)

- PHP 7.1+
- MySQL client/server version 5.6.x
- Gzip on the server (only tested on unix)

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

[](#installation)

You can install the package via composer:

```
composer require lily-labs/db-backup
```

For the backup process to work, it requires that you pre-configure a local login for mysql on your server using `mysql_config_editor` as follows:

```
mysql_config_editor set --login-path=local --host=localhost --user=username --password
```

Your database password will be asked after entering the command.

You can se more information [here](https://stackoverflow.com/a/20854048)

Usage
-----

[](#usage)

First create a `BackupFileNameGenerator`, this will generate the desire filename for the backup file, the default implementation `LilyLabs\DBBackup\BasicBackupFileNameGenerator` will generate a file name in this format: `"[database_name]_[year]-[month]-[day].sql"`

```
use LilyLabs\DBBackup\BasicBackupFileNameGenerator;
use LilyLabs\DBBackup\MysqldumpBackupProcessor;

$db_name = "DBTest";
$date = new DateTime('now');
$filename_generator = new BasicBackupFileNameGenerator($db_name, $date);
$filename = $filename_generator->getName(); // DBTest_[year]-[month]-[day].sql
```

Now, create an instance of `LilyLabs\DBBackup\MysqldumpBackupProcessor` to execute the backup process

```
$backup_processor = new MysqldumpBackupProcessor(
    $db_name,
    $filename_generator
);
$backup_file = $backup_processor->execute();
```

The returned object is an instance of `LilyLabs\DBBackup\DBBackupFile`, all backups are generated on the temp folder obtained by `sys_get_temp_dir()`, you can now move the file to your desired storage location.

```
$moved_backup_file = $backup_file->move("/final/location/of/the/backup");
```

Finally, you can use the class `LilyLabs\DBBackup\GzipCompressor` to gzip the backupfile:

```
$compressor = new \LilyLabs\DBBackup\GzipCompressor;
$compressed_backup_file = $compressor->compress($moved_backup_file);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Abraham Chávez](https://github.com/Geckomind)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

4

Last Release

1036d ago

### Community

Maintainers

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

---

Top Contributors

[![Geckomind](https://avatars.githubusercontent.com/u/1942860?v=4)](https://github.com/Geckomind "Geckomind (22 commits)")

---

Tags

dbbackupLilyLabsPHP MySQl Backup

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lily-labs-db-backup/health.svg)

```
[![Health](https://phpackages.com/badges/lily-labs-db-backup/health.svg)](https://phpackages.com/packages/lily-labs-db-backup)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[illuminate/console

The Illuminate Console package.

13045.3M6.2k](/packages/illuminate-console)[illuminate/process

The Illuminate Process package.

44813.9k97](/packages/illuminate-process)[digifactory/laravel-pull-production-data

Pull your production storage folder and database to your local environment

1016.9k](/packages/digifactory-laravel-pull-production-data)[verseles/sevenzip

A package to compress and decompress files using 7zip

191.8k](/packages/verseles-sevenzip)

PHPackages © 2026

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