91 lines
2.5 KiB
PHP
Executable File
91 lines
2.5 KiB
PHP
Executable File
<?php
|
|
include_once 'path.php';
|
|
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true)
|
|
exit(header("Location:../index.php"));
|
|
|
|
$current_selJob = $_POST['current_selJob'];
|
|
$archive_per = $_POST['archive'];
|
|
$_SESSION['file_offset'] = 1;
|
|
$_SESSION['archive_per'] = $archive_per;
|
|
$_SESSION['manual_per'] = $archive_per;
|
|
$_SESSION['backupLocation'] = Scheduler::GetHost($userName);
|
|
|
|
$archive_dir = Scheduler::$archiveclean_dir;
|
|
|
|
$temp = explode("_",$current_selJob,2);
|
|
$job_name = $temp[1];
|
|
$_SESSION['user_backup_set'] = $job_name;
|
|
$backupset_display = Scheduler::$backup_dir.$job_name."/".BACKUPSETFILEDISPLAY;
|
|
|
|
$_SESSION['backupset_display'] = $backupset_display;
|
|
$_SESSION['manual_backupset'] = Scheduler::$manual_dir;
|
|
$job_name = Scheduler::$manual_dir;
|
|
$jobcheckpath = Scheduler::$backup_dir;
|
|
$jobRunning = checkIfJobRunning($jobcheckpath); // checking any job is running
|
|
|
|
if($jobRunning == 1){
|
|
echo "JOB_RUN";
|
|
Scheduler::Log("Unable to start Archive Cleanup. Reason : Backup is in progress.");
|
|
exit;
|
|
}
|
|
$resultFile = "$archive_dir$job_name/".ARCHIVERESULT;
|
|
if(file_exists($resultFile)){
|
|
unlink($resultFile);
|
|
}
|
|
$tempDir = "$archive_dir$job_name/temp";
|
|
if(file_exists($tempDir))
|
|
shell_exec("rm -rf \"$tempDir\"");
|
|
|
|
|
|
$countFile = "$archive_dir$job_name/".ARCHIVECOUNT;
|
|
if(file_exists($countFile)){
|
|
unlink($countFile);
|
|
}
|
|
|
|
$cleanupStatusFile = "$archive_dir$job_name/".CLEANUP_STATUS;
|
|
if(file_exists($cleanupStatusFile)){
|
|
unlink($cleanupStatusFile);
|
|
}
|
|
|
|
$emptyFoldersList = "$archive_dir$job_name/".EMPTY_FOLDERS_LIST;
|
|
if(file_exists($emptyFoldersList)){
|
|
unlink($emptyFoldersList);
|
|
}
|
|
|
|
$pidDir = "$archive_dir/$job_name";
|
|
$pidPathForSearch = "$pidDir/$pidPath";
|
|
|
|
if(!is_dir($archive_dir)){
|
|
if(!mkdir($archive_dir, $permissionVal)){
|
|
echo "AR_DIR";
|
|
Scheduler::Log(AR_MANUAL . "[startarchive][$job_name]" . AR_DIR);
|
|
exit;
|
|
}
|
|
@chmod($archive_dir,$permissionVal);
|
|
}
|
|
|
|
if(!is_dir($pidDir)){
|
|
if(!mkdir($pidDir, $permissionVal)){
|
|
echo "JOB_DIR";
|
|
Scheduler::Log(AR_MANUAL . "[startarchive][$job_name]" . AR_JOB);
|
|
exit;
|
|
}
|
|
@chmod($pidDir,$permissionVal);
|
|
}
|
|
|
|
$phpBinaryPath = getphpPath();
|
|
$phpPath = "$appPath/".CONFIG;
|
|
if(SYNOLOGY_LOCAL == $machine || QNAP == $machine){
|
|
$cmd = "cd '$archive_dir$job_name'; $phpBinaryPath $phpPath/".CLEANUP_PHP." '$archive_per' '$backupset_display'";
|
|
$cmd = systemCmdExecution($cmd,0);
|
|
} else {
|
|
$cmd = "$phpBinaryPath $phpPath/".CLEANUP_PHP." '$archive_per' '$backupset_display'";
|
|
$cmd = systemCmdExecution($cmd,0, "'$archive_dir$job_name'");
|
|
}
|
|
|
|
pclose(popen("$cmd &","r"));
|
|
|
|
echo "yes";
|
|
|
|
?>
|