function start() { $sock = new sockets(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $unix = new unix(); $me = basename(__FILE__); if ($unix->process_exists(@file_get_contents($pidfile), $me)) { if ($GLOBALS["VERBOSE"]) { echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n"; } system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa"); die; } @file_put_contents($pidfile, getmypid()); $WordpressBackupParams = unserialize(base64_decode($sock->GET_INFO("WordpressBackupParams"))); if ($WordpressBackupParams["DEST"] == null) { $WordpressBackupParams["DEST"] = "/home/wordpress-backup"; } ScanFreeWebs($WordpressBackupParams); $t = time(); ftp_backup($WordpressBackupParams); }
function start() { $sock = new sockets(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $unix = new unix(); $me = basename(__FILE__); if ($unix->process_exists(@file_get_contents($pidfile), $me)) { if ($GLOBALS["VERBOSE"]) { echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n"; } system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa"); die; } @file_put_contents($pidfile, getmypid()); $zarafaserv = $unix->find_program("zarafa-server"); if (!is_file($zarafaserv)) { system_admin_events("zarafa-server, no such binary aborting...", __FUNCTION__, __FILE__, __LINE__, "zarafa"); die; } $ZarafaBackupParams = unserialize(base64_decode($sock->GET_INFO("ZarafaBackupParams"))); if ($ZarafaBackupParams["DEST"] == null) { $ZarafaBackupParams["DEST"] = "/home/zarafa-backup"; } if (!isset($ZarafaBackupParams["DELETE_BACKUPS_OLDER_THAN_DAYS"])) { $ZarafaBackupParams["DELETE_BACKUPS_OLDER_THAN_DAYS"] = 10; } if (!is_numeric($ZarafaBackupParams["DELETE_OLD_BACKUPS"])) { $ZarafaBackupParams["DELETE_OLD_BACKUPS"] = 1; } if (!is_numeric($ZarafaBackupParams["DELETE_BACKUPS_OLDER_THAN_DAYS"])) { $ZarafaBackupParams["DELETE_BACKUPS_OLDER_THAN_DAYS"] = 10; } $php = $unix->LOCATE_PHP5_BIN(); if (!is_file("/etc/cron.d/artica-zarafacleanbck")) { $f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin"; $f[] = "MAILTO=\"\"\n"; $f[] = "30 6 * * *\troot\t{$php} " . __FILE__ . " --clean-dirs >/dev/null 2>&1"; file_put_contents("/etc/cron.d/artica-zarafacleanbck", @implode("\n", $f)); chmod("/etc/cron.d/artica-zarafacleanbck", 0640); chown("/etc/cron.d/artica-zarafacleanbck", "root"); } build_script(); $t = time(); if ($GLOBALS["VERBOSE"]) { echo " -> /bin/artica-zarafa-backup.sh\n"; } exec("/bin/artica-zarafa-backup.sh 2>&1", $results); if ($GLOBALS["VERBOSE"]) { echo @implode("\n", $results) . "\n"; } $took = $unix->distanceOfTimeInWords($t, time(), true); system_admin_events("Backup done took:{$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "zarafa"); $NOW = date("Ymd"); $stamp = "{$ZarafaBackupParams["DEST"]}/{$NOW}/took.txt"; $datestamp = "{$ZarafaBackupParams["DEST"]}/{$NOW}/time.txt"; @file_put_contents($stamp, $took); @file_put_contents($datestamp, date("Y-m-d H:i:s")); ScanDirs(); RemoveDirs(); ftp_backup(); }
// var_dump([ // '/backup/'.$config['database']['filename'] => $config['database']['target'].'/'.$config['database']['filename'], // '/backup/'.basename($config['archive']['target']) => $config['archive']['target'], // ]); // exit; database_backup($config); $dir = __DIR__ . '/../h/'; $finder = new Finder(); $finder->files()->in($dir); $source = get_source($finder, '/h/' . $now . '/'); local_backup($config, $source); $finder2 = new Finder(); $finder2->files()->in($dir)->exclude('upload'); $source2 = get_source($finder2); archive_backup($config, $source2); ftp_backup($config, ['/backup/' . $config['database']['filename'] . '.gz' => $config['database']['target'] . '/' . $config['database']['filename'] . '.gz', '/backup/' . basename($config['archive']['target']) => $config['archive']['target']]); exit; // if ($config['database']['enabled'] === true) { // // $backupFiles = array_merge($backupFiles, database_backup($config)); // database_backup($config); // } // if ($config['local']['enabled'] === true) { // local_backup($config, $backupFiles); // } // if ($config['archive']['enabled'] === true) { // archive_backup($config, $backupFiles); // } // if ($config['ftp']['enabled'] === true) { // ftp_backup($config, $backupFiles); // } echo 'finished';