GithubHelp home page GithubHelp logo

pborreli / backup-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from backup-manager/backup-manager

0.0 1.0 0.0 392 KB

Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud.

backup-manager's Introduction

Database Backup Manager

Latest Stable Version License Build Status Coverage Status SensioLabsInsight Total Downloads

  • supports MySQL and PostgreSQL
  • compress with Gzip
  • framework-agnostic
  • dead simple configuration
  • optional integrations for MVC framework Laravel

Table of Contents

Stability Notice

This isn't a 1.0 release.

This initial release is VERY likely to have bugs and is also very like to change given feedback from users. Please feel free to submit feedback.

Quick and Dirty

Configure your databases.

// config/database.php
'development' => [
    'type' => 'mysql',
    'host' => 'localhost',
    'port' => '3306',
    'user' => 'root',
    'pass' => 'password',
    'database' => 'test',
],
'production' => [
    'type' => 'postgresql',
    'host' => 'localhost',
    'port' => '5432',
    'user' => 'postgres',
    'pass' => 'password',
    'database' => 'test',
],

Configure your filesystems.

// config/storage.php
'local' => [
    'type' => 'Local',
    'root' => '/',
],
's3' => [
    'type' => 'AwsS3',
    'key'    => '',
    'secret' => '',
    'region' => Aws\Common\Enum\Region::US_EAST_1,
    'bucket' => '',
    'root'   => '',
],
'rackspace' => [
    'type' => 'Rackspace',
    'username' => '',
    'password' => '',
    'container' => '',
    'root' => '',
],
'dropbox' => [
    'type' => 'Dropbox',
    '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' => '',
],

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.

$manager = require 'bootstrap.php';
$manager->makeBackup()->run('development', '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.4
  • 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

  1. Add the package to "require" in composer.json

For now, dev-master is fine since we're pre-1.0.

"require": {
    "heybigname/backup-manager": "dev-master"
}
  1. Update your composer packages.

composer update

Usage

Once installed, the package must be bootstrapped (initial configuration) before it can be used. If you're using Laravel then skip directly to the Laravel integration section.

We've provided a native PHP example here.

The required bootstrapping can be found in the example here.

Integrations

The backup manager is easy to integrate into your favorite frameworks. We've included Laravel integration. We're definitely accepting pull-requests.

Laravel

To install into a Laravel project, first do the composer install then add the following class to your config/app.php service providers list.

'BigName\BackupManager\Integrations\Laravel\BackupManagerServiceProvider',

Then, publish and modify the configuration file to suit your needs.

php artisan config:publish heybigname/backup-manager --path=vendor/heybigname/backup-manager/config

IoC Resolution

Manager can be automatically resolved through constructor injection thanks to Laravel's IoC container.

use BigName\BackupManager\Manager;

public function __construct(Manager $manager)
{
    $this->manager = $manager;
}

It can also be resolved manually from the container.

$manager = App::make('BigName\BackupManager\Manager');

Artisan Commands

There are three commands available manager:backup, manager:restore and manager:list.

All will prompt you with simple questions to successfully execute the command.

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:

  • please conform to the code style of the project, it's essentially PSR-2 with a few differences.
    1. The NOT operator when next to parenthesis should be surrounded by a single space. if ( ! is_null(...)) {.
    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.
  • 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 Mitchell van Wijngaarden and Shawn McCool of Big Name

License

The MIT License (MIT)

Copyright (c) 2014 Big Name

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

backup-manager's People

Contributors

driesvints avatar mikulas avatar mitchellvanw avatar

Watchers

 avatar

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.