symandy / database-backup-bundle
A Symfony Bundle to handle databases backup
Installs: 575
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 2
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=8.1
- nyholm/dsn: ^2.0
- symfony/config: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/http-kernel: ^6.0
- symfony/process: ^6.0
- symfony/property-access: ^6.0
- symfony/serializer: ^6.0
Requires (Dev)
- doctrine/orm: ^2.11
- friendsofphp/php-cs-fixer: ^3.16
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^9.5
- symfony/console: ^6.0
- symfony/dotenv: ^6.0
- symfony/framework-bundle: ^6.0
- symfony/phpunit-bridge: ^6.0
- symfony/yaml: ^6.0
- webmozart/assert: ^1.11
README
DatabaseBackupBundle is a Symfony Bundle to manage your databases backup.
Installation
composer require symandy/database-backup-bundle
If Symfony Flex is not enabled yet for the bundle (A PR on
symfony/recipes-contrib will be submitted soon), add the following lines
to config/bundles.php
.
<?php return [ ... Symandy\DatabaseBackupBundle\SymandyDatabaseBackupBundle::class => ['all' => true], ... ];
Configuration
YAML configuration
As in the previous part, if Symfony Flex is not enabled, add the following file (symandy_database_backup.yaml
)
to config/packages
directory.
Basic configuration
If the only purpose is to back up the database of the current project, use the basic configuration file.
symandy_database_backup: backups: app: connection: url: "%env(DATABASE_URL)%" strategy: max_files: 5 backup_directory: "%kernel.project_dir%/backups"
Advanced usages
symandy_database_backup: backups: foo: connection: # driver: !php/const \Symandy\DatabaseBackupBundle\Model\ConnectionDriver::MySQL driver: mysql # Usage of environment variables as parameters is recommended for connections configuration configuration: user: "%app.foo_db_user%" password: "%app.foo_db_password%" host: 127.0.0.1 # Already the default value, don't need to be added port: 3306 # Already the default value, don't need to be added databases: [foo, bar, baz] # Will only back up these databases strategy: max_files: 5 # Number of files kept after a backup (per database) # backup_directory: "/var/www/backups" # The directory must be created and must have the right permissions backup_directory: "%kernel.project_dir%/backups" # backup_directory: ~ # The current directory will be used if no value is passed date_format: 'Y-m-d-His' # The date format to use in backup files (default: 'Y-m-d') bar: # Use Doctrine database url env parameter connection: url: "%env(DATABASE_URL)%" # url key will ALWAYS override array configuration configuration: user: john # Overridden by url
Drivers
Only the mysql
driver is currently available.
Usage
Once the backups are configured, you only have to run the following command to generate the dumped databases backup files:
php bin/console symandy:databases:backup
It will generate one file by database in the format <backup_name>-<database>-<date_format>.sql
.
Changelog
You can see all the changes between versions here in the CHANGELOG.md or in the GitHub releases page