Code Monkey home page Code Monkey logo

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

symfony's People

Contributors

benr77 avatar branlute avatar cklm avatar hason avatar innerflamefact avatar jsunier avatar karser avatar lcp0578 avatar lhpalacio avatar mavinbe avatar mscharl avatar nmeirik avatar nyholm avatar piskvor avatar shivoham avatar trsteel88 avatar wartab avatar ymezard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony's Issues

Fatal error: Environment variables "DATABASE_URL" are never used. Please, check your container's configuration.

I'm currently testing #39. I've updated the config for this bundle at config/packages/bm_backup_manager.yaml to look like this:

bm_backup_manager:
    database:
        development:
            dsn: '%env(DATABASE_URL)%'
        production:
            dsn: '%env(DATABASE_URL)%'
    storage:
        local:
            type: Local
            root: /home/elvismdev/WWW/my_sf4_app/_db_backup

Now, when I run the command to fire the DB backup:

php bin/console backup-manager:backup development local -c gzip

It throws this fatal error:
selection_139

On other hand, if instead using %env(DATABASE_URL)% for the DSN value I place directly in the yaml file my DB details like mysql://root:[email protected]:3306/test, it does works and backups the DB successfully as expected.

If that helps, I found a similar issue/error reported here symfony/symfony#23520

Use with AsyncAWS instead of AwsSDK

Hello.
Is it possible to use this package with AsyncAWS instead of the full bloated AwsSdk.

So AsyncAws\Flysystem\S3\AsyncAwsS3Adapter instead of League\Flysystem\AwsS3v3\AwsS3Adapter

Thanks

Bundle does not work with Symfony 3

I installed the bundle as directed in the README. However, I get the following error when trying to run the Symfony Console:

[Symfony\Component\Console\Exception\LogicException]
The command defined in "BM\BackupManagerBundle\Command\BackupCommand" cannot have an empty name.

This is easily fixed by passing a name to the parent constructor of the BackupCommand class a string.

ie. parent::__construct('bp:backup');

Release new version

Hi, I would like to use this bundle with Symfony 3.2 - but version 1.0 only supports Symfony 2.x. Since it's a bad practice to relay on dev-master, can you please tag a version 1.1?
Thanks!

undefined method named "scalarPrototype" - Symfony 3.2

Hi,
I installed the bundle on my Symfony 3.2 project.
I get this exception :

UndefinedMethodException in Configuration.php line 92:
Attempted to call an undefined method named "scalarPrototype" of class "Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition".

scalarPrototype method seems to be included on the 3.3 version.
Do you think you can use the old method to extends the compatibility?

New in version 3.3: The arrayPrototype() method (and the related booleanPrototype() integerPrototype(), floatPrototype(), scalarPrototype() and enumPrototype()) was introduced in Symfony 3.3. In previous versions, you needed to use prototype('array'), prototype('boolean'), etc.

Thanks

SYMFONY5 SUPPORT FOR SYMFONY/PROCESS

Hi

When I tried to update to 2.3.* I got this error

Problem 1
- backup-manager/backup-manager 1.4.1 requires symfony/process ^2.1 || ^3.0 || ^4 -> no matching package found.
- backup-manager/backup-manager 1.4 requires symfony/process ^2.1 || ^3.0 || ^4.0 -> no matching package found.
- backup-manager/backup-manager 1.3.0 requires symfony/process ^2.1 || ^3.0 || ^4.0 -> no matching package found.
- backup-manager/symfony 2.3.0 requires backup-manager/backup-manager ^1.3 -> satisfiable by backup-manager/backup-manager[1.3.0, 1.4, 1.4.1].
- Installation request for backup-manager/symfony 2.3.* -> satisfiable by backup-manager/symfony[2.3.0].

But I have the symfony/process in 5.0.3 version. Any idea?

Config not loaded Flex

Filename : bm_backup_manager.yml
Dir: config/packages

config:debug show an empty config so its not loaded

Bundle fails on dsn define

mysql://user:pass@server:3306/database

And show me:
mysqldump: Got error: 1049: "Unknown database '/database'" when selecting the database. I think that this take the '/' too.

Symfony 5 support

The bundle does not appear to support the newly released Symfony 5. When attempting to upgrade an installation with the software installed, I get the following error:

backup-manager/symfony 2.2.0 requires symfony/console ^2.7 || ^3.1 || ^4.0 -> satisfiable by symfony/console[v4.3.8] but these conflict with your requirements or minimum-stability.

Could not find configuration for connection local

Hello :),

parameters:
    bdd.backup.dir: "/var/www/html/backup"

bm_backup_manager:
    database:
        db:
            dsn: '%env(resolve:DATABASE_URL)%'
    storage:
#        local:
#            type: Local
#            root: "%bdd.backup.dir%"
        local_backup:
            type: Local
            root: "%bdd.backup.dir%"
        local_tmp:
            type: Local
            root: "/tmp"
php bin/console backup-manager:restore db local_tmp /ed_611712.sql.gz -c gzip

Multiple local folders cannot be configured. It tries to take the "local" configuration :

Could not find configuration for connection local

Error on DNS

Since the update, I have 2 errors on my environments :

The provided DSN is not valid. Maybe you need to url-encode the user/password? (root:XXXXX@host:3306/db?serverVersion=5.7)

Database /db not found

It used to work properly before the new release

Add support for league/flysystem v2.

Hello,

In league/flysystem-aws-s3-v3, the AwsS3Adaptor class has been renamed to AWSS3V3Adaptor. When trying to upgrade to the newer version of flysystem (in order to work with other updated dependencies), ~v2.0 of flysystem is required.

Are there plans to upgrade this library to support v2? Would you prefer a PR?

Thank you.

Not Working with PHP8.1 and Symfony6

Hi all

I was trying to update the bundle but I got these errors

  • backup-manager/symfony 3.2.0 requires php ^7.3 -> your php version (8.1.6) does not satisfy that requirement.
  • backup-manager/symfony 3.2.1 requires symfony/config ^3.4 || ^4.4 || ^5.0 -> found symfony/config[v3.4.0, ..., v3.4.47, v4.4.0, ..., v4.4.41, v5.0.0, ..., v5.4.8] but the package is fixed to v6.0.8 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
  • Root composer.json requires backup-manager/symfony ^3.2 -> satisfiable by backup-manager/symfony[3.2.0, 3.2.1].

I saw in the Issues Closed what it was working with this environment. Any idea?

Thanks

Installation

Hi, I am encountering problems during installation of the bundle. I'm working with Symfony 5.1.8 (but the project originally started with Symfony 2), php 7.4.9 with wamp 3.2.3.3. I'm using the 3.1.1 version of BackupManager
As written in the README, I installed the bundle with composer require backup-manager/symfony. It worked well, so I configured the yaml and then directly used the line $this->container->get('backup_manager')->... in my Controller. I got an the following error :

image

As it told me, I tried dependency injection with
use BackupManager\Manager; passing Manager $manager in my function and replaced $this->container->get('backup_manager')-> by $manager-> and inserted BackupManager\Manager: ~ in my services.yaml
Then I got the error :

image

I looked at the file BM\BackupManagerBundle\BMBackupManagerBundle and it is empty, is it normal ? Shouldn't it insert all the classes for autowiring ?
I'm new to Symfony so don't hesitate to correct me I may make mistakes.
Thank you very much

Missing on packagist

This package is not on packagist. So the command composer require ... not works.

Bump requirements to allow for PHP 8 ?

The composer.json requirements currently do not allow for PHP 8.

Has anyone tried to run the tests on that version and if so, do the tests cover enough to allow for a bump in requirements?

Currently running composer require backup-manager/symfony will try to install version 1.1 since that version simply required "php": ">=5.5" which is probably not what was intended. The debugging of why I got a conflict with other packages took some time and I guess I will not be the last.

Files backup

Please add configurable files backup, why backup only database.

DropboxV2 type not being recognized

DropboxV2 is not being recognized. Any fix for this?

In composer.json, the appropriate Dropbox library is included
"backup-manager/backup-manager": "^1.2"
"srmklive/flysystem-dropbox-v2": "^1.0",

issue

Get DB parameters from Symfony 4 .env file

Hi again,

So now I encounter with the issue that in new SF4 the way to define the DB details are in a one line only, and not with each piece (user, pass, host, dbname) being separated like this bundle needs.

https://symfony.com/doc/current/configuration.html#the-env-file-environment-variables

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=mysql://root:[email protected]:3306/test_db
###< doctrine/doctrine-bundle ###

Is there a way backup-manager bundle can get/resolve all the database parameters needed from this DATABASE_URL environment variable?

Docummentation and configuration

I'm using your bundle to make backups but there are 2 issues :

  • doc from symfony2 bundle is not uptodate according to this line : $manager->makeBackup()->run('development', [new Destination('s3', 'test/backup.sql')], 'gzip'); from https://github.com/backup-manager/backup-manager

  • you should add a very important parameter "ignoreTables" option in Configuration

                          ->arrayNode('ignoreTables')
                              ->prototype('scalar')->end()
                          ->end()
    

And i would abandon my fork to come back to your bundle ;)

thanks !

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.