Public | Automated Build

Last pushed: 6 months ago
Short Description
Fast MySQL import export with rules (mysqldump)
Full Description

DiabloSQL

Fast MySQL import export with rules

Installation

Step 1 Installation

Extract diablosql.zip in /opt/diablosql

Step default backup configuration

More option see mysqldump --help

array(
    'host' => NULL,
    'user' => NULL,
    'password' => NULL,
    'database' => NULL,
    'compress' => FALSE,
    'directory' => NULL,
    'quick' => TRUE,
    'lock-tables' => FALSE,
    'ignore-tables' => NULL,
    'only-tables' => NULL,
    'log-error' => NULL,
    'process-max' => 4,
    'process-sleep' => 2,
    'clear-dir' => TRUE,
    'gzip-output' => FALSE
);

Step default restore configuration

More options see mysql --help

array(
    'host' => NULL,
    'user' => NULL,
    'password' => NULL,
    'database' => NULL,
    'directory' => NULL,
    'quick' => TRUE,
    'lock-tables' => FALSE,
    'ignore-tables' => NULL,
    'only-tables' => NULL,
    'log-error' => NULL,
    'process-max' => 4,
    'process-sleep' => 2
);

Step 2 Exemple backup file

Configuration /opt/diablosql/etc/backup/databasename.php

<?php
require_once(__DIR__.'/../../src/Diablo/Diablo.php');

$diablo = new DiabloBackup(array(
    'host' => 'localhost',
    'user' => 'root',
    'password' => '',
    'database' => 'databasename',
    'directory' => '/opt/diablosql/sql/databasename',
    'log-error' => '/opt/diablosql/log/databasename-backup-error.log',
    'protocol' => 'tcp',
    'max-allowed-packet' => '16M',
    'process-max' => 4
), array(
    'user' => array('where' => "date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW()"),
    'log' => array('no-data' => TRUE)
));

$diablo->run();

Step 4 Exemple restore file

Configuration /opt/diablosql/etc/restore/databasename.php

<?php
require_once(__DIR__.'/../../src/Diablo/Diablo.php');

$diablo = new DiabloRestore(array(
    'host' => 'localhost',
    'user' => 'root',
    'password' => '',
    'database' => 'databasename',
    'directory' => '/opt/diablosql/sql/databasename',
    'log-error' => '/opt/diablosql/log/databasename-restore-error.log',
    'protocol' => 'tcp',
    'max-allowed-packet' => '16M',
    'process-max' => 4
));

$diablo->run();

Step 5 Execute

Step 5.1 Only backup the database

$ php /opt/diablosql/etc/backup/databasename.php

Step 5.2 Only restore the database

$ php /opt/diablosql/etc/backup/databasename.php

Step 5.3 both

$ sh /opt/diablosql/bin/run.sh

Step 5.4 Crontab

Create a file /etc/cond.d/diablosql

0    0    *    *    *    root    docker exec host_diablosql_1 sh bin/run.sh > /dev/null 2>&1
Docker Pull Command
Owner
maltyxx
Source Repository

Comments (0)