kmj/syncbundle

Symfony2 Bundle that handles the synchronization between a production site and test/development servers

Installs: 1 044

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Type:symfony-bundle

dev-master 2016-03-29 21:40 UTC

This package is not auto-updated.

Last update: 2024-10-26 14:59:58 UTC


README

Welcome to the KMJSyncBundle. The goal of this project to ease the hassle of getting live data to your development and testing servers. This bundle takes the specified folders and the production database and compresses them into a tar file. The development servers can then request the latest backup, download it, and install it.

  1. Installation

KMJSyncBundle can conveniently be installed via Composer. Just add the following to your composer.json file:

// composer.json
{
    // ...
    require: {
        // ..
        "kmj/syncbundle": "dev-master"
    }
}

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

    php composer.phar update

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new KMJ\SyncBundle\KMJSyncBundle(),
    // ...
);
  1. Configuration

This bundle comes with a few configuration options.

api_syncing:
   dir:                 #The working directory for the bundle, no data is stored here. Defaults to %kernel.root_dir%/cache/sync
   backups:             #The directory to store all the backups. Defaults to %kernel.root_dir%/Resources/backups
   compression:         #The compression method to be used for the backup files. Only supported one at the moment is tar
   numberofbackups:     #The number of backups to keep Defaults to 3
  
   ## ALL OF THESE ARE REQUIRED ##

paths:                  #Array of directories to compress
      - path:           #The path for the folder to be backed up. Example:%kernel.root_dir%/../web/uploads

   database:            #Production database credentials
      type: mysql       #Mysql is the only supported type
      host:             #Production server database host
      database:         #Production server database name
      user:             #Production server database username
      password:         #Production server database password 
   ssh:
     host:              #Production server host name
     port: 2100         #Production server port
     username:          #Production server username
     path:              #Path to the root of the site
  1. Usage

On the production server a command like

app/console kmj:sync:backup --env=prod

will generate a backup file to that the other development and testing servers can download it

On your testing servers all you need to do is run

app/console kmj:sync:sync

This will download the backup file, extract it's contents, dump the current database and reload it with production data and finally move any folders to their original location.