forked from k2s/xtbackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxtbackup.php
65 lines (56 loc) · 1.75 KB
/
xtbackup.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
65
<?php
/**
* Main program
*
* Loads the backup engine and passes command line arguments to it.
* Then it runs all required steps to execute backup task.
*
*
*/
// make sure we will find include files
set_include_path(realpath(dirname(__FILE__)));
// make some more adjustments to PHP configuration
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
ini_set('html_errors', false);
ini_set('log_errors', false);
ini_set('ignore_repeated_errors', false);
ini_set('ignore_repeated_source', false);
ini_set('report_memleaks', true);
ini_set('track_errors', true);
ini_set('docref_root', 0);
ini_set('docref_ext', 0);
error_reporting(E_ALL | E_STRICT);
set_time_limit(0);
// load engine core
require_once 'core/Engine.php';
// show help message
$helpIdx = array_search("--help", $argv);
if (false!==$helpIdx) {
echo "TODO some help text for this command line application\n";
exit(Core_StopException::RETCODE_OK);
}
// it is possible to suppress output to console in start phase of engine
$quiteStartIdx = array_search("--quite-start", $argv);
if (false!==$quiteStartIdx) {
unset($argv[$quiteStartIdx]);
}
// we need quite output if initializing INI file from start of the engine
$initIdx = array_search("--init", $argv);
if (false!==$initIdx || false!==$quiteStartIdx) {
$output = false;
} else {
// default output will be used in start phase of engine
$output = null;
}
// initialize backup engine
$engine = new Core_Engine($argv, $output);
// show help message and stop if requested
if (false!==$initIdx) {
echo $engine->generateIni();
exit(Core_StopException::RETCODE_OK);
}
$engine->setAppHelpMessage("Use command line parameter --help to see usage instructions.");
$engine->init();
$engine->run();
exit($engine->finish());