Coder Social home page Coder Social logo

databasebackupbundle's Introduction

DatabaseBackupBundle

DatabaseBackupBundle is a Symfony Bundle to manage your databases backup.

Build

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

databasebackupbundle's People

Contributors

svillette avatar dirkdrutschmann avatar giordanovi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.