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

tsslabs/cloud-backup-bundle

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

  • Saturday, August 30, 2014
  • by radutopala
  • Repository
  • 1 Watchers
  • 0 Stars
  • 104 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 57 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status, (*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 (with the help of DropboxUploader by hakre) * CloudApp (thanks to CloudAPP-API-PHP-wrapper) * Amazon S3 (through KnpGaufretteBundle) * Google Drive (soon..), (*5)

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

are supported :-), (*7)

Installation (>=Symfony 2.1)

Composer

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

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

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

Adding bundle to your application kernel

// app/AppKernel.php

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

Configuration

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

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 
    folders: [ web/uploads , other/folder ]
    cloud_storages:
        # Dropbox account credentials (use parameters in config.yml and store real values in prameters.yml)
        dropbox:
            user:     ~  # Required
            password: ~  # Required
            remote_path: ~ # Not required, default "/", but you can use path like "/Accounts/backups/"
        # 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 service name

    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: ~

        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.:, (*11)

# app/config/config.yml
dizda_cloud_backup:
    cloud_storages:
        dropbox:
            user:        %dizda_cloud_dropbox_user%
            password:    %dizda_cloud_dropbox_password%
            remote_path: %dizda_cloud_dropbox_remote_path%


    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_user:     myDropboxUser
    dizda_cloud_dropbox_password: MyDropboxPassword
    dizda_cloud_mongodb_user:     mongodbUser
    dizda_cloud_mongodb_password: mongodbPass
    # ...

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 :, (*12)

# m h  dom mon dow   command
0 6 * * * php /opt/www/symfony-project/app/console dizda:backup:start

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

$ crontab -u www-data -e

or simply, (*14)

$ php app/console dizda:backup:start

, (*15)

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

Capifony integration

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

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

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:, (*19)

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

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

End

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

It is Symfony2.1, 2.2 and 2.3 compatible, I'll make some tests as soon as time permits., (*21)

Enjoy, PR are welcome !, (*22)

The Versions

30/08 2014

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

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