PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Jasenko Rakovic   Maratus PHP Backup Databases   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Full example
Class: Maratus PHP Backup Databases
Backup many types of database to multiple storages
Author: By
Last change:
Date: 9 years ago
Size: 2,978 bytes
 

Contents

Class file image Download
<?php

require 'vendor/autoload.php';

use
Dzasa\MaratusPhpBackup\MaratusBackup;

$backup = new MaratusBackup();

$dbConfig = array(
  
'type' => 'mysql',
  
'host' => "localhost",
  
'port' => 3306,
  
'user' => 'root',
  
'pass' => '',
  
'database' => ''
);

$backup->addDatabase($dbConfig);

$dbConfigPg = array(
  
'type' => 'postgresql',
  
'host' => "localhost",
  
'port' => 5432,
  
'user' => '',
  
'pass' => '',
  
'database' => ''
);

$backup->addDatabase($dbConfigPg);

$dbConfigMongo = array(
  
'type' => 'mongodb',
  
'database' => '',
  
'host' => '',
  
'user' => 'dzasa',
  
'pass' => ''
);

$backup->addDatabase($dbConfigMongo);

$couchDbConfig = array(
'type' => 'couchdb',
'remote' => true,
'host' => 'localhost',
'user' => 'root',
'pass' => '',
'database' => '',
);
$backup->addDatabase($couchDbConfig);

$dbConfig2 = array(
  
'type' => 'mysql',
  
'host' => "localhost",
  
'port' => 3306,
  
'user' => '',
  
'pass' => '',
  
'database' => ''
);
$backup->addDatabase($dbConfig2);

$dBoxConfig = array(
  
'type'=> 'dropbox',
  
'access_token' => ''
);

$backup->addStorage($dBoxConfig);

$gDriveConfig = array(
  
'type'=> 'gdrive',
  
'client_id' => '',
  
'client_secret' => '',
  
'token_file' => 'gdrive-token.json',
  
'auth_code' => ''
);
$backup->addStorage($gDriveConfig);

$redisConfig = array(
'type' => 'redis',
'remote' => true,
'host' => '192.168.1.1',
'user' => 'root',
'private_key' => '',
'private_key_pass' => '',
'database_path' => "/var/lib/redis/dump.rdb",
);

$backup->addDatabase($redisConfig);

$riakConfig = array(
'type' => 'riak',
'remote' => true,
'host' => '192.168.1.1',
'user' => 'root',
'private_key' => '',
'private_key_pass' => '@',
'bitcask_path' => '/var/lib/riak/bitcask',
'leveldb_path' => '/var/lib/riak/leveldb',
'strong_consistency_path' => '/var/lib/riak/ensembles',
'remote_compress' => 'zip',
);
$backup->addDatabase($riakConfig);

$sqliteConfig = array(
   
'type' => 'sqlite',
   
'remote' => true,
   
'host' => '192.168.1.1',
   
'user' => 'root',
   
'private_key' => '',
   
'private_key_pass' => '',
   
'remote_compress' => 'zip',
   
'database_path' => '/root/backup',
);
$backup->addDatabase($sqliteConfig);

$copyConfig = array(
   
'type' => 'copy',
   
'consumer_key' => '',
   
'consumer_secret' => '',
   
'access_token' => '',
   
'token_secret' => '',
);

$backup->addStorage($copyConfig);

$localStorageConfig = array(
   
'type' => 'local',
   
'save_dir' => 'test2',
);

$backup->addStorage($localStorageConfig);

$ftpStorage = array(
   
'type' => 'ftp',
   
'host' => '192.168.1.1',
   
'user' => '',
   
'pass' => '',
   
'remote_dir' => 'test2',
);
$backup->addStorage($ftpStorage);

$backup->backup("tar.bz2");

print_r($backup->getDatabaseBackupResult());
echo
"-----------------------------\n";
print_r($backup->getStorageBackupResult());