Git Product home page Git Product logo

symfony's Introduction

Database Backup Manager

Latest Stable Version License Total Downloads

This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud.

  • use version 2+ for >=PHP 7.3
  • use version 1 for <PHP 7.2

Watch a video tour showing the Laravel driver in action to give you an idea what is possible.

Table of Contents

Quick and Dirty

Configure your databases.

// config/database.php
'development' => [
    'type' => 'mysql',
    'host' => 'localhost',
    'port' => '3306',
    'user' => 'root',
    'pass' => 'password',
    'database' => 'test',
    // If singleTransaction is set to true, the --single-transcation flag will be set.
    // This is useful on transactional databases like InnoDB.
    // http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
    'singleTransaction' => false,
    // Do not dump the given tables
    // Set only table names, without database name
    // Example: ['table1', 'table2']
    // http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_ignore-table
    'ignoreTables' => [],
    // using ssl to connect to your database - active ssl-support (mysql only):
    'ssl'=>false,
    // add additional options to dump-command (like '--max-allowed-packet')
    'extraParams'=>null,
],
'production' => [
    'type' => 'postgresql',
    'host' => 'localhost',
    'port' => '5432',
    'user' => 'postgres',
    'pass' => 'password',
    'database' => 'test',
],

Configure your filesystems.

// config/storage.php
'local' => [
    'type' => 'Local',
    'root' => '/path/to/working/directory',
],
's3' => [
    'type' => 'AwsS3',
    'key'    => '',
    'secret' => '',
    'region' => 'us-east-1',
    'version' => 'latest',
    'bucket' => '',
    'root'   => '',
    'use_path_style_endpoint' => false,
],
'b2' => [
    'type' => 'B2',
    'key'    => '',
    'accountId' => '',
    'bucket' => '',
],
'gcs' => [
    'type' => 'Gcs',
    'key'    => '',
    'secret' => '',
    'version' => 'latest',
    'bucket' => '',
    'root'   => '',
],
'rackspace' => [
    'type' => 'Rackspace',
    'username' => '',
    'key' => '',
    'container' => '',
    'zone' => '',
    'root' => '',
],
'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' => '',
],
'flysystem' => [
    'type' => 'Flysystem',
    'name' => 's3_backup',
    //'prefix' => 'upload',
],
'doSpaces' => [
    'type' => 'AwsS3',
    'key' => '',
    'secret' => '',
    'region' => '',
    'bucket' => '',
    'root' => '',
    'endpoint' => '',
    'use_path_style_endpoint' => false,
],
'webdav' => [
    'type' => 'Webdav',
    'baseUri' => 'http://myserver.com',
    'userName' => '',
    'password' => '',
    'prefix' => '',
],

Backup to / restore 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.

use BackupManager\Filesystems\Destination;

$manager = require 'bootstrap.php';
$manager->makeBackup()->run('development', [new Destination('s3', 'test/backup.sql')], 'gzip');

Backup to / restore from any configured filesystem.

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

$manager = require 'bootstrap.php';
$manager->makeRestore()->run('s3', 'test/backup.sql.gz', 'development', '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 5.5
  • 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

Installation

Composer

Run the following to include this via Composer

composer require backup-manager/backup-manager

Then, you'll need to select the appropriate packages for the adapters that you want to use.

# to support s3
composer require league/flysystem-aws-s3-v3

# to support b2
composer require mhetreramesh/flysystem-backblaze

# to support google cs
composer require league/flysystem-aws-s3-v2

# to install the preferred dropbox v2 driver
composer required spatie/flysystem-dropbox

# to install legacy dropbox v2 driver
composer require srmklive/flysystem-dropbox-v2

# to support rackspace
composer require league/flysystem-rackspace

# to support sftp
composer require league/flysystem-sftp

# to support webdav (supported by owncloud nad many other)
composer require league/flysystem-webdav

Usage

Once installed, the package must be bootstrapped (initial configuration) before it can be used.

We've provided a native PHP example here.

The required bootstrapping can be found in the example here.

Contribution Guidelines

We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run vagrant up in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you.

When contributing please consider the following guidelines:

  • Code style is PSR-2
    • Interfaces should NOT be suffixed with Interface, Traits should NOT be suffixed with Trait.
  • All methods and classes must contain docblocks.
  • Ensure that you submit tests that have minimal 100% coverage. Given the project's simplicity it just makes sense.
  • When planning a pull-request to add new functionality, it may be wise to submit a proposal to ensure compatibility with the project's goals.

Maintainers

This package is maintained by Shawn McCool and you!

Backwards Compatibility Breaks

3.0

Remove support for symfony 2. Specifically symfony/process versions < 3.x

License

This package is licensed under the MIT license. Go wild.

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

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

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

Files backup

Please add configurable files backup, why backup only database.

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.

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.

Missing on packagist

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

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?

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

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.

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

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.

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 !

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

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

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

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

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');

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

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.