PHPackages                             tito10047/migration-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. tito10047/migration-backup

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

tito10047/migration-backup
==========================

Symfony bundle that automatically backs up your database (MySQL, PostgreSQL, SQLite) before running migrations. Supports Gzip compression and automatic cleanup.

2.0.1(1mo ago)0502MITPHPPHP &gt;=8.2CI passing

Since Jun 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/tito10047/migration-backup)[ Packagist](https://packagist.org/packages/tito10047/migration-backup)[ RSS](/packages/tito10047-migration-backup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (28)Versions (14)Used By (0)

🛡️ Migration Backup Bundle
==========================

[](#️-migration-backup-bundle)

[![Build Status](https://github.com/tito10047/migration-backup/actions/workflows/tests.yml/badge.svg)](https://github.com/tito10047/migration-backup/actions)[![Latest Stable Version](https://camo.githubusercontent.com/e79049c3e314e21fac2d4f8ca76d1ede07d404a88edd31a132f6b1215de9596d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7469746f31303034372f6d6967726174696f6e2d6261636b75702e737667)](https://packagist.org/packages/tito10047/migration-backup)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/5814289f8aa8cd4671b9582f7c4172d2d1af7fccd603b5d707234f0e02ad69d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393262662e737667)](https://php.net)[![Symfony Version](https://camo.githubusercontent.com/d667415dd34ff31d986621444fb17659993b42fd9bd49c64bbb45f09de2c0eaa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d253345253344253230362e342d626c61636b3f6c6f676f3d73796d666f6e79)](https://symfony.com/)[![Coverage Status](https://camo.githubusercontent.com/13c5613c7db365004cbac4598d1a90d0231caad2f26dffe314fbe656d1b2f5d7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7469746f31303034372f6d6967726174696f6e2d6261636b75702f62616467652e737667)](https://coveralls.io/github/tito10047/migration-backup)

### Did you run a migration and it "crashed" in the middle? Welcome to hell. 🔥

[](#did-you-run-a-migration-and-it-crashed-in-the-middle-welcome-to-hell-)

You know the drill: you run `doctrine:migrations:migrate`, the third command out of ten fails, and you're left with a broken database. Revert doesn't work because half the changes were applied and half weren't. You don't know exactly what was executed and what wasn't. Manual repair is a nightmare, and if you had settings or data in the database that can't just be "re-run" via fixtures... well, good luck.

**Migration Backup Bundle is your rescue parachute.** It automatically backs up your database right before the first migration starts. If anything goes wrong, you have a clean restore point to return to immediately.

✨ Features
----------

[](#-features)

- 🚀 **Automatic backup** before running migrations.
- 🗜️ **Compression support**: Multi-format support (Gzip, Bzip2, Zstandard, Zip, LZ4) to reduce backup size.
- 🧹 **Automatic Cleanup**: Keep e.g. only the last 10 backups and save space.
- 🧩 **Extensible**: Easily add your own custom compressor.
- 🐘 **Multi-DB support**: Full support for **MySQL**, **PostgreSQL**, and **SQLite**.
- 🔔 **Events**: Ability to hook into your own logic (Slack notifications, logging, etc.).

📦 Installation
--------------

[](#-installation)

```
composer require tito10047/migration-backup
```

*(If you are not using Symfony Flex, don't forget to register the bundle in `config/bundles.php`)*

⚙️ Configuration
----------------

[](#️-configuration)

Create the file `config/packages/migration_backup.yaml`:

```
migration_backup:
    # Directory for storing backups (default is %kernel.project_dir%/backup)
    backup_path: '%kernel.project_dir%/var/backups'

    # Which DB connections you want to back up (can be multiple)
    database: ['default']

    # How many last backups to keep (0 = all)
    keep_last_n_backups: 5

    # Should the backup be compressed?
    compress: true

    # Compression format to use (default: gzip)
    # Available options: gzip, bzip2, zstd, zip, lz4, none
    compression_format: 'gzip'

    # Paths to binaries (if not available globally in PATH)
    backup_binary: 'mysqldump'    # For MySQL
    pg_dump_binary: 'pg_dump'      # For PostgreSQL
```

🚀 Usage
-------

[](#-usage)

The bundle does not activate itself automatically during every migration (to avoid slowing you down during development). To create a backup, just add the `--backup` flag (or the shortcut `-b`) to the command:

> **Note:** This bundle is primarily intended for the **development environment**, but there is nothing stopping you from using it in **production** as well.

```
php bin/console doctrine:migrations:migrate --backup
```

The console output will inform you of the success: `Backup of database default created in /your/project/var/backups/default-2024-03-11-15-55-01.sql.gz`

🗜️ Compression
--------------

[](#️-compression)

The bundle supports several compression formats. Each format requires its corresponding PHP extension to be installed:

FormatExtensionFile ExtensionRecommendation**Gzip**`zlib``.gz`Standard, well-balanced.**Bzip2**`bz2``.bz2`Better compression ratio, slower.**Zstandard**`zstd``.zst`Modern, fast with great compression.**Zip**`zip``.zip`Highly compatible across OS.**LZ4**`lz4``.lz4`Extremely fast compression.**None**--No compression.If the required extension is missing, the bundle will throw a `RuntimeException` when attempting to use that format.

### Custom Compressor

[](#custom-compressor)

You can implement your own compression logic by creating a class that implements `Tito10047\MigrationBackup\Compressor\CompressorInterface`.

Then, register your service and alias the `migration_backup.compressor` to it:

```
# config/services.yaml
services:
    App\Backup\MyCustomCompressor:
        arguments: ['@symfony_filesystem_service']

    migration_backup.compressor:
        alias: App\Backup\MyCustomCompressor
```

Note: If you override the `migration_backup.compressor` service, the `compression_format` setting in `migration_backup.yaml` will be ignored. It's cleaner to set it to `none` to avoid confusion.

🛠️ Supported Databases
----------------------

[](#️-supported-databases)

- **MySQL**: requires `mysqldump` to be installed.
- **PostgreSQL**: requires `pg_dump` to be installed.
- **SQLite**: standard file access is enough (automatically copies the `.db` file).

🪝 Events for Developers
-----------------------

[](#-events-for-developers)

The bundle triggers the following events that you can listen to:

- `Tito10047\MigrationBackup\Event\BackupStartedEvent`
- `Tito10047\MigrationBackup\Event\BackupFinishedEvent`
- `Tito10047\MigrationBackup\Event\BackupFailedEvent`

---

Developed for a peaceful sleep with every deploy. 😊

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Recently: every ~14 days

Total

12

Last Release

57d ago

Major Versions

0.0.4 → 1.0.02025-04-18

1.0.4 → v2.x-dev2026-03-11

PHP version history (2 changes)0.0.1PHP &gt;=8.1

1.0.2PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d6d558226302620ec462f64672e9dc81609227626923a808005641e76e8c38f?d=identicon)[tito10047](/maintainers/tito10047)

---

Top Contributors

[![tito10047](https://avatars.githubusercontent.com/u/11459248?v=4)](https://github.com/tito10047 "tito10047 (47 commits)")

---

Tags

backupdoctrinedoctrinemigrationsbundlesymfony

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tito10047-migration-backup/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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