-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_migrate.php
executable file
·64 lines (52 loc) · 1.78 KB
/
backup_migrate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env php
<?php
// backup_migrate.php
require __DIR__.'/vendor/autoload.php';
use BackupMigrate\Core\Config\Config;
use BackupMigrate\Core\File\TempFileManager;
use BackupMigrate\Core\Filter\CompressionFilter;
use BackupMigrate\Core\Filter\FileNamer;
use BackupMigrate\Core\Plugin\PluginManager;
use BackupMigrate\Core\Service\ServiceLocator;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\StreamOutput;
use BackupMigrate\Core\Main\BackupMigrate;
use BackupMigrate\Core\Destination\StreamDestination;
use BackupMigrate\Core\File\TempFileAdapter;
use BackupMigrate\CLI\Command\BackupCommand;
// Load up the config file for the database settings.
$config = require './config.php';
$output = new StreamOutput(fopen('php://stderr', 'w'));
// Create the service locator
$services = new ServiceLocator();
$services->add('Logger',
new ConsoleLogger($output)
);
$services->add('TempFileManager',
new TempFileManager(new TempFileAdapter('/tmp'))
);
// Create the plugin manager
$plugins = new PluginManager($services);
// Load the plugins specified in the config.
foreach ($config['plugins'] as $id => $plugin) {
$plugins->add(
$id,
new $plugin['type'](new Config($plugin['config']))
);
}
// Add the stdout destination
$plugins->add(
'stdout',
new StreamDestination(new Config(['streamuri' => 'php://stdout']))
);
$plugins->add('compression', new CompressionFilter());
$plugins->add('name', new FileNamer());
// Configure the plugins
$plugins->setConfig(new Config($config['config']));
// Create the service object.
$bam = new BackupMigrate($plugins);
$application = new Application();
$application->add(new BackupCommand($bam));
$application->run(null, $output);
$bam->plugins()->setConfig(['db' => []]);