PHPackages                             raffaelecarelle/symfony-pro-backup-bundle - 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. raffaelecarelle/symfony-pro-backup-bundle

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

raffaelecarelle/symfony-pro-backup-bundle
=========================================

Symfony bundle for database and filesystem backup/restore management

0.1.0(5mo ago)179MITPHPPHP &gt;=8.2CI passing

Since Nov 6Pushed 5mo ago2 watchersCompare

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

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

Symfony Backup Bundle
=====================

[](#symfony-backup-bundle)

A Symfony bundle for database and filesystem backup/restore management.

Overview
--------

[](#overview)

The Symfony Backup Bundle provides a complete and configurable system for automatic and manual backups of databases and filesystems, with optional Symfony Profiler integration for development.

Features
--------

[](#features)

- Database backup and restore (MySQL, PostgreSQL, SQLite)
- Filesystem backup and restore
- Multiple storage adapters (Local, S3, Google Cloud)
- Compression support (gzip, zip)
- Retention policy helpers
- Scheduler/Messenger integration for automated backups (Symfony 7.3+)
- Event system for backup/restore operations
- Command-line interface and programmatic API

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

[](#requirements)

- PHP: &gt;= 8.2
- Symfony: 6.4+

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

[](#installation)

```
composer require raffaelecarelle/symfony-backup-bundle
```

### Profiler

[](#profiler)

If you enabled profiler section import the profiler routing file:

```
# config/routes/profiler.yaml
_profiler_pro_backup:
    resource: "@ProBackupBundle/Resources/config/routes.php"
```

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

[](#configuration)

Create a configuration file at `config/packages/pro_backup.yaml`:

```
pro_backup:
    default_storage: 'local'
    backup_dir: '%kernel.project_dir%/var/backups'

    storage:
        local:
            adapter: 'local'
            options:
                path: '%kernel.project_dir%/var/backups'
                permissions: 0755

        s3:
            adapter: 's3'
            options:
                bucket: 'my-app-backups'
                region: 'eu-west-1'
                credentials:
                    key: '%env(AWS_ACCESS_KEY_ID)%'
                    secret: '%env(AWS_SECRET_ACCESS_KEY)%'

        google_cloud:
            adapter: 'google_cloud'
            options:
                bucket: 'my-app-backups'
                project_id: '%env(GOOGLE_CLOUD_PROJECT_ID)%'
                key_file: '%env(GOOGLE_CLOUD_KEY_FILE)%'

    database:
        enabled: true
        connections: ['default'] # Doctrine connection names
        compression: 'gzip'      # gzip|zip|null
        retention_days: 30
        exclude_tables: ['cache_items', 'sessions']
        options:
            mysql:
                single_transaction: true
                routines: true
                triggers: true
            postgresql:
                format: 'custom'
                verbose: true

    filesystem:
        enabled: false
        paths:
            - { path: '%kernel.project_dir%/public/uploads', exclude: ['*.tmp', '*.log'] }
            - { path: '%kernel.project_dir%/config', exclude: ['secrets/'] }
        compression: 'zip'
        retention_days: 7

    schedule:
        database:
            frequency: 'daily' # daily, weekly, monthly, cron expression
            time: '02:00'
        filesystem:
            frequency: 'weekly'
            time: '03:00'
```

Usage
-----

[](#usage)

### Console commands

[](#console-commands)

Create a database backup:

```
php bin/console pro:backup:create --type=database
```

Restore a backup:

```
php bin/console pro:backup:restore
```

List available backups:

```
php bin/console pro:backup:list
```

### Programmatic usage

[](#programmatic-usage)

```
use ProBackupBundle\Model\BackupConfiguration;
use ProBackupBundle\Manager\BackupManager;

// Create a backup
$config = (new BackupConfiguration())
    ->setType('database')
    ->setName('my_backup');

$backupManager = $container->get(BackupManager::class);
$result = $backupManager->backup($config);

if ($result->isSuccess()) {
    echo 'Backup created: ' . $result->getFilePath();
} else {
    echo 'Backup failed: ' . $result->getError();
}

// Restore a backup
$backupId = 'backup_123';
$success = $backupManager->restore($backupId, []);

if ($success) {
    echo 'Backup restored successfully';
} else {
    echo 'Restore failed';
}
```

Architecture
------------

[](#architecture)

### Database Adapter Auto-Detection

[](#database-adapter-auto-detection)

The bundle automatically detects the database type from your Doctrine DBAL connection configuration using a factory pattern. The `DatabaseAdapterFactory` inspects the database platform at runtime using `Connection::getDatabasePlatform()` and creates the appropriate adapter (MySQL, PostgreSQL, SQLite).

This approach is robust and works with:

- Modern DSN-based configuration (`postgresql://user:pass@host/db`)
- Legacy driver-based configuration (`pdo_pgsql`, `pdo_mysql`)
- Multiple database connections
- Any Doctrine-supported database platform

No manual adapter selection is required - the bundle automatically uses the correct backup tool (`mysqldump`, `pg_dump`, `sqlite3`) based on your connection type.

### Supported Database Platforms

[](#supported-database-platforms)

- **MySQL/MariaDB**: Uses `mysqldump` and `mysql` for backup/restore
- **PostgreSQL**: Uses `pg_dump` and `pg_restore`/`psql` for backup/restore
- **SQLite**: Uses file-based backup with `sqlite3` CLI

Make sure the corresponding CLI tools are available in your system PATH.

Events
------

[](#events)

The bundle dispatches the following events (see `ProBackupBundle\Event\BackupEvents`):

- `backup.pre_backup`: Before a backup operation
- `backup.post_backup`: After a successful backup operation
- `backup.failed`: When a backup operation fails
- `backup.pre_restore`: Before a restore operation
- `backup.post_restore`: After a successful restore operation
- `backup.restore_failed`: When a restore operation fails

Development
-----------

[](#development)

- Run CS fixer (dry-run): `vendor/bin/php-cs-fixer fix --dry-run --diff`
- Run static analysis: `vendor/bin/phpstan analyse`
- Run tests: `vendor/bin/phpunit`

CI runs on GitHub Actions with MySQL and PostgreSQL services and a matrix of PHP/Symfony versions compatible with this bundle.

License
-------

[](#license)

This bundle is released under the MIT License.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance71

Regular maintenance activity

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

2

Last Release

166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/470d7f2b64c268ccd0d73d1d19da604f5049ffdc717170df28ac460d34b8a327?d=identicon)[raffaelecarelle](/maintainers/raffaelecarelle)

---

Top Contributors

[![raffaelecarelle](https://avatars.githubusercontent.com/u/15015792?v=4)](https://github.com/raffaelecarelle "raffaelecarelle (113 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/raffaelecarelle-symfony-pro-backup-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/raffaelecarelle-symfony-pro-backup-bundle/health.svg)](https://phpackages.com/packages/raffaelecarelle-symfony-pro-backup-bundle)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

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

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

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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