Example #1
0
function backup_cyrus($ID)
{
    $date_start = time();
    $users = new usersMenus();
    if (!$users->cyrus_imapd_installed) {
        backup_events($ID, "cyrus-imap", "INFO, cyrus-impad NOT Installed", __LINE__);
        return true;
    }
    $q = new mysql();
    $sql = "SELECT COUNT(ID) as tcount FROM `system_schedules` WHERE `TaskType`=69 AND `enabled`=1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if ($ligne["tcount"] > 0) {
        backup_events($ID, "cyrus-imap", "INFO, Dedicated cyrus-backup was scheduled, aborting", __LINE__);
        return true;
    }
    if ($GLOBALS["COMMANDLINECOPY"] == null) {
        backup_events($ID, "cyrus-imap", "ERROR, COMMANDLINECOPY is null", __LINE__);
        return false;
    }
    $partition_default = $users->cyr_partition_default;
    $config_directory = $users->cyr_config_directory;
    backup_events($ID, "cyrus-imap", "INFO, partition-default={$partition_default}\nDirectory config={$config_directory}");
    backup_mkdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/partitiondefault");
    backup_mkdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory");
    if (!backup_isdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory")) {
        backup_events($ID, "cyrus-imap", "ERROR, {$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory permission denied or no such file or directory", __LINE__);
        return false;
    }
    $info = backup_copy($config_directory, "{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory", $ID, __LINE__);
    backup_events($ID, "cyrus-imap", "INFO,configdirectory\n{$info}");
    $info = backup_copy($partition_default, "{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/partitiondefault", $ID, __LINE__);
    backup_events($ID, "cyrus-imap", "INFO,partitiondefault\n{$info}");
    $cmd = "su - cyrus -c \"{$users->ctl_mboxlist} -d >/tmp/mailboxlist.txt\"";
    exec($cmd, $results);
    if (!is_file("/tmp/mailboxlist.txt")) {
        backup_events($ID, "cyrus-imap", "ERROR,unable to export mailbox list\n{$cmd}\n" . implode("\n", $results));
    }
    $info = backup_copy("/tmp/mailboxlist.txt", "{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/mailboxlist.txt", $ID, __LINE__);
    backup_events($ID, "cyrus-imap", "INFO, mailboxlist.txt\n{$info}", __LINE__);
    $date_end = time();
    $calculate = distanceOfTimeInWords($date_start, $date_end);
    backup_events($ID, "cyrus-imap", "INFO, time: {$calculate}", __LINE__);
}
Example #2
0
function backup_cyrus($ID){
	$date_start=time();
	$users=new usersMenus();
	if(!$users->cyrus_imapd_installed){
		backup_events($ID,"cyrus-imap","INFO, cyrus-impad NOT Installed");
		return true;
	}
	
	if($GLOBALS["COMMANDLINECOPY"]==null){
		backup_events($ID,"cyrus-imap","ERROR, COMMANDLINECOPY is null");
		return false;
	}
	
	$partition_default=$users->cyr_partition_default;
	$config_directory=$users->cyr_config_directory;

	backup_events($ID,"cyrus-imap","INFO, partition-default=$partition_default\nDirectory config=$config_directory");
	
	backup_mkdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/partitiondefault");
	backup_mkdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory");
	
	if(!backup_isdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory")){
		backup_events($ID,"cyrus-imap","ERROR, $mounted_path/cyrus-imap/configdirectory permission denied or no such file or directory");
		return false;
	}

	$info=backup_copy($config_directory,"{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/configdirectory",$ID);
	backup_events($ID,"cyrus-imap","INFO,configdirectory\n$info");
	$info=backup_copy($partition_default,"{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/partitiondefault",$ID);
	backup_events($ID,"cyrus-imap","INFO,partitiondefault\n$info");
	$cmd="su - cyrus -c \"$users->ctl_mboxlist -d >/tmp/mailboxlist.txt\"";
	exec($cmd,$results);
	
	if(!is_file("/tmp/mailboxlist.txt")){
		backup_events($ID,"cyrus-imap","ERROR,unable to export mailbox list\n$cmd\n".implode("\n",$results));
	}
	$info=backup_copy("/tmp/mailboxlist.txt","{$GLOBALS["MOUNTED_PATH_FINAL"]}/cyrus-imap/mailboxlist.txt",$ID);
	backup_events($ID,"cyrus-imap","INFO, mailboxlist.txt\n$info");
	$date_end=time();
	$calculate=distanceOfTimeInWords($date_start,$date_end);
	backup_events($ID,"cyrus-imap","INFO, time: $calculate");
	
}