Merge pull request #7548 from stephenwaite/iss7501-take-4
[openemr.git] / interface / main / backuplog.php
blobd2e4cd585efdacacd048bb6d913408f5fec23561
1 <?php
3 /**
4 * backuplog.php
6 * Here /interface/globals.php is not referred, because it includes sqlconf.php
7 * Pass these variables $webserver_root & $_GLOBALS[backup_log_dir] as parameters for CRON.
9 * @package OpenEMR
10 * @link http://www.open-emr.org
11 * @author ViCarePlus, Visolve <vicareplus_engg@visolve.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) ViCarePlus, Visolve <vicareplus_engg@visolve.com>
14 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
15 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
18 // Ensure running from command line only
19 if (php_sapi_name() !== 'cli') {
20 exit;
23 require_once("$argv[1]/library/sqlconf.php");
24 $backuptime = date("Ymd_His");
25 $BACKUP_EVENTLOG_DIR = $argv[2] . "/emr_eventlog_backup";
26 if (!file_exists($BACKUP_EVENTLOG_DIR)) {
27 mkdir($BACKUP_EVENTLOG_DIR);
28 chmod($BACKUP_EVENTLOG_DIR, 0777);
31 $BACKUP_EVENTLOG_DIR = $BACKUP_EVENTLOG_DIR . '/eventlog_' . $backuptime . '.sql';
32 $cmd = escapeshellcmd($argv[1] . '/interface/main/backuplog.sh') . ' ' . escapeshellarg($sqlconf["login"]) . ' ' . escapeshellarg($sqlconf["pass"]) . ' ' . escapeshellarg($sqlconf["dbase"]) . ' ' . escapeshellarg($BACKUP_EVENTLOG_DIR) . ' ' . escapeshellarg($sqlconf["host"]) . ' ' . escapeshellarg($sqlconf["port"]);
33 system($cmd);