Git Product home page Git Product logo

backup-manager-symfony's Introduction

BackupManagerBundle

Latest Stable Version License Build Status Total Downloads

A simple database backup manager for Symfony with support for S3, Rackspace, Dropbox, FTP, SFTP.

This package pulls in the framework agnostic Backup Manager and provides seamless integration with Symfony.

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require backup-manager/symfony

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2 (with Flex): Enable the Bundle

You do not need to do anything more. The bundle is enabled automatically and you have some nice default config in config/packages/bm_backup_manager.yml.

Step 2 (no Flex): Enable the Bundle

If you are not using Symfony Flex, you need to enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project.

// config/bundles.php

return [
    BM\BackupManagerBundle\BMBackupManagerBundle::class => ['all' => true],
    // ...
];

Step 3: Configure your databases and filesystems

# config/packages/bm_backup_manager.yml

bm_backup_manager:
    database:
        development:
            type: mysql
            host: localhost
            port: 3306
            user: root
            pass: password
            database: test
            ignoreTables: ['foo', 'bar']

            # If DSN is specified, it will override other values
            dsn: 'mysql://root:[email protected]:3306/test_db'
        production:
            type: postgresql
            host: localhost
            port: 5432
            user: postgres
            pass: password
            database: test

            # You could also use a environment variable
            dsn: '%env(resolve:DATABASE_URL)%'
    storage:
        local:
            type: Local
            root: /path/to/working/directory
        s3:
            type: AwsS3
            key:
            secret:
            region: us-east-1
            version: latest
            bucket:
            root:
        b2:
            type: B2
            key:
            accountId:
            bucket:
        rackspace:
            type: Rackspace
            username:
            password:
            container:
        dropbox:
            type: DropboxV2
            token:
            key:
            secret:
            app:
            root:
        ftp:
            type: Ftp
            host:
            username:
            password:
            root:
            port: 21
            passive: true
            ssl: true
            timeout: 30
        sftp:
            type: Sftp
            host:
            username:
            password:
            root:
            port: 21
            timeout: 10
            privateKey:

Usage

To backup from any configured database.

Backup the development database to Amazon S3. The S3 backup path will be test/backup.sql.gz in the end, when gzip is done with it.

class Foo {
  private $backupManager;

  public function __construct(BackupManager $backupManager) {
      $this->backupManager = $backupManager;
  }

  public function bar() {
      $this->backupManager->makeBackup()->run('development', [new Destination('s3', 'test/backup.sql')], 'gzip');
  }
}

Or with a command:

php bin/console backup-manager:backup development s3 -c gzip --filename test/backup.sql

To restore from any configured filesystem.

Restore the database file test/backup.sql.gz from Amazon S3 to the development database.

class Foo {
  private $backupManager;

  public function __construct(BackupManager $backupManager) {
      $this->backupManager = $backupManager;
  }

  public function bar() {
      $this->backupManager->makeRestore()->run('s3', 'test/backup.sql.gz', 'development', 'gzip');
  }
}

Or with a command:

php bin/console backup-manager:restore development s3 test/backup.sql.gz -c gzip

This package does not allow you to backup from one database type and restore to another. A MySQL dump is not compatible with PostgreSQL.

Requirements

  • PHP 7.3
  • MySQL support requires mysqldump and mysql command-line binaries
  • PostgreSQL support requires pg_dump and psql command-line binaries
  • Gzip support requires gzip and gunzip command-line binaries

backup-manager-symfony's People

Contributors

nyholm avatar mscharl avatar nmeirik avatar lhpalacio avatar ymezard avatar benr77 avatar karser avatar piskvor avatar jsunier avatar hason avatar innerflamefact avatar shivoham avatar branlute avatar trsteel88 avatar wartab avatar youvalteboul avatar cklm avatar lcp0578 avatar mavinbe 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.