Coder Social home page Coder Social logo

mybackup's Introduction

MyBackup

Project to make database backups based on MySQL. Inspired and based on mysqldump-php.

Try to create backup with a guided example

Call method create. This method required a instance of Connection. This class is a DTO with database required info (dsn, username and password):

    new Connection(
        'mysql:host=mysserver.com;dbname=myuser', 'myuser', 'password'
    ),

Complete example:

require_once './vendor/autoload.php';

use MyBackup\Backup;
use MyBackup\Connection;

Backup::create(
    new Connection(
        'mysql:host=myserver.com;dbname=mydb', 'myuser', 'password'
    ),
    dirname(__FILE__) . '/storage/dump.sql'
);

Anothers options to create a MySQL backup

Create with conditions

Mapping with tableName and SQL condition.

$tableConditions = array(
    'users' => 'date_registered > NOW() - INTERVAL 3 MONTH AND deleted=0',
    'logs' => 'date_logged > NOW() - INTERVAL 1 DAY',
    'posts' => 'isLive=1'
);

createWithConditions($connection, $storagePath, $tableConditions);

Create with limits

Mapping with tableName and row date limit.

$tableLimits = array(
    'users' => 300,
    'logs' => 50,
    'posts' => 10
);

createWithRateLimits(Connection $connection, $storagePath, $tableLimits);

Create complete backup

Create with table conditions and row date limits

createComplete(Connection $connection, $storagePath, $tableConditions, $tableLimits);

Trace log backup info

  • Define afeter backup create:
Backup::log(
    function($table) {
        print_r(
            "Tabla " . $table->name() . " con un total de " . $table->rows() . " filas. \n"
        );
    }
);

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.