2017 © Pedro Peláez
 

symfony-bundle cloud-backup-bundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

image

dizda/cloud-backup-bundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  • Tuesday, January 31, 2017
  • by dizda
  • Repository
  • 17 Watchers
  • 188 Stars
  • 78,941 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 57 Forks
  • 26 Open issues
  • 42 Versions
  • 5 % Grown

The README.md

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

CloudBackupBundle

This bundle helps you to backup your databases and upload it to the cloud with only one Symfony2 command., (*2)

You can : * Dump one database * Dump all databases * Different types of databases can be dumped each time * Upload to several Cloud services, (*3)

Databases supported : * MongoDB * MySQL * PostgreSQL (excluding all_databases option), (*4)

Cloud services supported : * Dropbox (Dropbox SDK) * CloudApp (thanks to CloudAPP-API-PHP-wrapper) * Amazon S3 (through KnpGaufretteBundle or OneupFlysystemBundle) * Google Drive (thanks to HappyrGoogleSiteAuthenticatorBundle) * Rackspace (through OneupFlysystemBundle), (*5)

But also : * Local (through KnpGaufretteBundle or OneupFlysystemBundle) * FTP (through KnpGaufretteBundle or OneupFlysystemBundle) * sFTP (through KnpGaufretteBundle or OneupFlysystemBundle) * GridFS (through KnpGaufretteBundle or OneupFlysystemBundle) * MogileFS (through KnpGaufretteBundle) * WebDAV (through OneupFlysystemBundle), (*6)

are supported :-), (*7)

Compressors supported : * Tar - fast and medium effective, don't support password * Zip - fast and medium effective, support password * 7zip - very slow and very effective, support password, (*8)

Splitters supported:, (*9)

  • ZipSplit - split a zipfile into smaller zipfiles

Installation (>=Symfony 2.1)

Composer

Download CloudBackupBundle and its dependencies to the vendor directory. You can use Composer for the automated process:, (*10)

$ php composer.phar require dizda/cloud-backup-bundle

Composer will install the bundle to vendor/dizda directory., (*11)

Adding bundle to your application kernel

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Dizda\CloudBackupBundle\DizdaCloudBackupBundle(),
        // ...
    );
}

Configuration

Here is the default configuration for the bundle:, (*12)

dizda_cloud_backup:
    # By default backup files will have your servers hostname as prefix
    # such as: hostname_2014-01-01_21-08-39.tar
    output_file_prefix: hostname
    timeout: 300
    restore: false # Set to true to enable restore command
    processor:
        type: tar # Required: tar|zip|7z
        options:
            compression_ratio: 6
            password: qwerty
            # Split into many files of `split_size` bytes
            split:
                enable: false # Default false
                split_size: 1000 # Make each zip files no larger than "split_size" in bytes
                storages: [ Dropbox, CloudApp, GoogleDrive, Gaufrette ] # Which cloud storages will upload split files
    folders: [ web/uploads , other/folder ]
    cloud_storages:
        # Local storage definition
        local:
            path: ~ # Required
        # CloudApp account. Can be optional, like dropbox.
        cloudapp:
            user:        ~ # Required
            password:    ~ # Required
        # or you can use Gaufrette as well (optional)
        gaufrette:
            service_name:   # Gaufrette filesystem(s) service name
                - local_backup_filesystem
                - amazon_backup_filesystem
        flysystem:
            service_name: # Flysystem filesystem(s) service name
                - oneup_flysystem.acme_filesystem
        google_drive:
          token_name: ~ # Required
          remote_path: ~ # Not required, default "/", but you can use path like "/Accounts/backups/"
        # Using dropbox via official API. You need to add "dropbox/dropbox-sdk": "1.1.*" in your composer.json file
        dropbox_sdk:
            remote_path: ~ # Required. Path to upload files (where the root '/' will be application folder)
            access_token: ~ # Required. Access token provided by DropBox to authenticate your application. You can follow instructions at https://www.dropbox.com/developers/core/start/php

    databases:
        mongodb:
            all_databases: false # Only required when no database is set
            database:     ~ # Required if all_databases is false
            db_user:     ~ # Not required, leave empty if no auth is required
            db_password: ~ # Not required

        mysql:
            all_databases: false # Only required when no database is set
            database: ~          # Required if all_databases is false
            db_host: localhost   # This, and following is not required and if not specified, the bundle will take ORM configuration in parameters.yml
            db_port: ~           # Default 3306
            db_user: ~
            db_password: ~
            ignore_tables:       # Specify full name if dumping all databases. `dbname.tablename`
                - table1
                - table2

        postgresql:
            database: dbname     # Required
            db_host: localhost   # This, and following is not required and if not specified, the bundle will take ORM configuration in parameters.yml
            db_port: ~           # Default 5432
            db_user: ~
            db_password: ~

It is recommended to keep real values for logins and passwords in your parameters.yml file, e.g.:, (*13)

# app/config/config.yml
dizda_cloud_backup:
    processor:
        type: tar
        options:
            password: %dizda_cloud_archive_password%

    cloud_storages:
        dropbox_sdk:
            access_token: %dizda_cloud_dropbox_token%
            remote_path: /backup

    databases:
        mongodb:
            all_databases: false
            database: %dizda_cloud_mongodb_user%
            db_user:  %dizda_cloud_mongodb_user%
            db_pass:  %dizda_cloud_mongodb_password%

        mysql:
            # When no parameters is specified under mysql, the bundle taking those from parameters.yml

        postgresql:
            # When no parameters is specified under postgresql, the bundle taking those from parameters.yml
# app/config/parameters.yml
    # ...
    database_driver: pdo_mysql
    database_host: localhost
    database_port: null
    database_name: myDatabase
    database_user: myLogin
    database_password: myDatabasePassword
    # ...
    dizda_cloud_dropbox_token:     myDropboxUser
    dizda_cloud_mongodb_user:     mongodbUser
    dizda_cloud_mongodb_password: mongodbPass
    dizda_cloud_archive_password: ArchivePassword
    # ...

Usage

The bundle adds one command to symfony console: app/console dizda:backup:start which you execute periodically as a cron job. For example the following cron command dumps your database every days at 6am on a server :, (*14)

# m h  dom mon dow   command
0 6 * * * cd /var/www/yourproject && php app/console --env=prod dizda:backup:start > /dev/null 2>&1

Info : To edit crontab for the user www-data (to prevent permissions error) :, (*15)

$ crontab -u www-data -e

or simply, (*16)

$ php app/console --env=prod dizda:backup:start

, (*17)

In addition, using -F or --folder option the folders also will be added to the backup., (*18)

Obviously, if some problems occurs during the backup process, you can configure monolog to send you emails., (*19)

When working locally or on a staging server, you can configure the bundle to enable restoring. Set restore: true and the following command is available:, (*20)

$ php app/console dizda:backup:restore --force

Note! Not all processors, clients and databases supports restoring. Backupped files are not restored., (*21)

Which archiver do I use?

tar and zip archivers are produce the same size of compressed file, but tar compresses faster. 7z archiver is very slow, but has double effectiveness. tar archiver do not support encryption, other archivers support., (*22)

Note Your system may not have the zip and 7z archivers installed. But tar is installed in common case., (*23)

Guide to choice: * If you don't need password protection and you have enough disk space, the best choice is tar. * If you need password protection and you have enough disk space, the best choice is zip. * If you haven't enough disk space (or you will do backup often) and you backup only text data (e.g. database dumps), the best choice is 7z., (*24)

Note Any archiver good compress text files (and better compress structured texts e.g. sql, css, html/xml). But binary files (images, audio, video) will not be well compressed. If you have small database dump and big binary data, the best choice will be tar or zip., (*25)

Comparison of archivers, (*26)

Uncompressed archive contents sql dump of 42.2M size. This table represents effectiveness of archivers. Third column contents compressed archive file and percent of compression (low is better). Fourth column contents compression time and its ratio (to first line) (low is better)., (*27)

archiver compression archive size execution time
tar default (6) 8.78M (20.8%) 4.44s (1.00x)
tar best (9) 8.45M (20.0%) 9.89s (2.23x)
zip default (6) 8.78M (20.8%) 5.39s (1.21x)
zip best (9) 8.45M (20.0%) 11.03s (2.48x)
7z default (5) 4.42M (10.5%) 31.06s (7.00x)
7z best (9) 4.24M (10.0%) 38.88s (8.76x)

Capifony integration

If you are using capifony for deployment you can grab the sample task for easier backups., (*28)

Add the following task in your deploy.rb file, (*29)

namespace :symfony do
    namespace :dizda do
        namespace :backup do
            desc "Upload a backup of your database to cloud service's"
            task :start do
                run "#{try_sudo} sh -c 'cd #{current_release} && #{php_bin} #{symfony_console} dizda:backup:start #{console_options}'"
            end
        end
    end
end

This adds symfony:dizda:backup:start command to capifony. To launch it automatically on deploy you might use:, (*30)

# 1) Launches backup right before deploy
before "deploy", "symfony:dizda:backup:start"

# 2) Launches backup after deploy
after "deploy", "symfony:dizda:backup:start"

Report to Deadmanssnitch.com

To be sure your backup scripts are actually run you can report each successful backup to deadmanssnitch.com using DeadmanssnitchBundle., (*31)

End

This bundle was inspired from KachkaevDropboxBackupBundle., (*32)

Enjoy, PR are welcome !, (*33)

The Versions

31/01 2017

dev-master

9999999-dev https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

31/01 2017

3.5.0

3.5.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

14/12 2016

3.4.2

3.4.2.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

18/11 2016

3.4.1

3.4.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

18/10 2016

3.4.0

3.4.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

23/05 2016

3.3.0

3.3.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

25/01 2016

3.2.4

3.2.4.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

18/01 2016

3.2.3

3.2.3.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

07/12 2015

3.2.2

3.2.2.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

10/11 2015

3.2.1

3.2.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

09/11 2015

3.2.0

3.2.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

07/11 2015

3.1.0

3.1.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

29/10 2015

3.0.1

3.0.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

02/10 2015

3.0.0

3.0.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

01/10 2015

dev-dropboxsdk

dev-dropboxsdk https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

07/09 2015

2.2.0

2.2.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

04/09 2015

2.1.1

2.1.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

03/09 2015

2.1.0

2.1.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

05/08 2015

2.0.2

2.0.2.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

27/06 2015

2.0.1

2.0.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

20/03 2015

2.0.0

2.0.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

12/02 2015

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

12/02 2015

1.9.0

1.9.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

09/02 2015

1.8.0

1.8.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

23/01 2015

1.7.1

1.7.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

23/01 2015

1.7.0

1.7.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

20/01 2015

1.6.3

1.6.3.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

20/01 2015

1.6.2

1.6.2.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

12/12 2014

1.6.1

1.6.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

21/11 2014

1.6.0

1.6.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

30/09 2014

1.5.5

1.5.5.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

29/09 2014

dev-fix-timeout

dev-fix-timeout https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

19/09 2014

1.5.4

1.5.4.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

13/09 2014

1.5.3

1.5.3.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

21/07 2014

1.5.2

1.5.2.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

06/05 2014

1.5.1

1.5.1.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

05/05 2014

1.5.0

1.5.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

26/09 2013

1.4.0

1.4.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

19/07 2013

1.3.0

1.3.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

23/06 2013

1.2.0

1.2.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

21/02 2013

1.1.0

1.1.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive

20/02 2013

1.0.0

1.0.0.0 https://github.com/dizda/CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, CloudApp, GoogleDrive, etc.)

  Sources   Download

MIT

The Requires

 

mongodb database symfony mysql dump dropbox cloudapp googledrive gdrive