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. lily-labs/db-backup

ActiveLibrary

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)042↓100%MITPHPPHP ^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 2mo ago

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

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

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

983d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce4ad63028f1df3fcd97fc867b1fdc08fb5666ce4db7a70f3ef79af9c0c9465b?d=identicon)[Geckomind](/maintainers/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

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[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.

44643.1k1](/packages/pressbooks-pressbooks)[illuminate/process

The Illuminate Process package.

44699.5k65](/packages/illuminate-process)[statamic/cli

Statamic CLI Tool

7587.7k](/packages/statamic-cli)

PHPackages © 2026

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