コード例 #1
0
ファイル: backup.php プロジェクト: Satariall/izurit
 function Scan($path)
 {
     $this->path = $path;
     if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path)) {
         foreach ($arCloudFiles['file'] as $k => $file) {
             if ($this->last_bucket_path) {
                 if ($path . '/' . $file == $this->last_bucket_path) {
                     $this->last_bucket_path = '';
                 } else {
                     continue;
                 }
             }
             $name = $this->path = $path . '/' . $file;
             if (!haveTime()) {
                 // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
                 return false;
             }
             $HTTP = new CHTTP();
             if ($HTTP->Download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT . BX_ROOT . '/backup/clouds/' . $this->id . $name)) {
                 $this->download_size += $arCloudFiles['file_size'][$k];
                 $this->download_cnt++;
             } else {
                 $this->arSkipped[] = $name;
             }
         }
     }
     foreach ($arCloudFiles['dir'] as $dir) {
         if ($this->last_bucket_path) {
             if ($path . '/' . $dir == $this->last_bucket_path) {
                 $this->last_bucket_path = '';
             } elseif (strpos($this->last_bucket_path, $path . '/' . $dir) !== 0) {
                 continue;
             }
         }
         if ($path . '/' . $dir == '/bitrix/backup') {
             continue;
         }
         if ($path . '/' . $dir == '/tmp') {
             continue;
         }
         if (!$this->Scan($path . '/' . $dir)) {
             // partial
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: dump.php プロジェクト: nProfessor/Mytb
					if ($r === 0)
						$NS["step"]++;
				}
				$tar->close();
			}
		}
		else
			$NS["step"]++;
	}

	// Step 6: Send to the cloud 
	if($NS["step"] == 6)
	{
		if ($NS['BUCKET_ID'])
		{
			if (haveTime())
			{
				if (!CModule::IncludeModule('clouds'))
					RaiseErrorAndDie(GetMessage("MAIN_DUMP_NO_CLOUDS_MODULE"));

				$file_size = filesize($NS["arc_name"]);
				$obUpload = new CCloudStorageUpload(substr($NS['arc_name'],strlen(DOCUMENT_ROOT)));
				if (!$obUpload->isStarted())
				{
					if (!$obUpload->Start(intval($NS['BUCKET_ID']), $file_size))
					{
						if ($e = $APPLICATION->GetException())
							$strError = $e->GetString();
						else
							$strError = GetMessage('MAIN_DUMP_INT_CLOUD_ERR');
						RaiseErrorAndDie($strError);
コード例 #3
0
ファイル: restore.php プロジェクト: ASDAFF/open_bx
	function restore()
	{
		if (!$this->_dFile = fopen($this->DBdump, 'r'))
		{
			$this->db_Error = "Can't open file: ".$this->DBdump;
			return false;
		}

		if($this->d_pos > 0)
			fseek($this->_dFile, $this->d_pos);

		$sql = "";

		while(($sql = $this->readSql()) && haveTime())
		{
			if (defined('VMFREETRIX')) // избавимся от MyISAM
			{
				if (preg_match('#^CREATE TABLE#i',$sql))
				{
					$sql = preg_replace('#ENGINE=MyISAM#i','',$sql);
					$sql = preg_replace('#TYPE=MyISAM#i','',$sql);
				}
			}

			$result = @mysql_query($sql, $this->db_Conn);

			if(!$result && mysql_errno() != 1062)
			{
				$this->db_Error .= mysql_error().'<br><br>'.htmlspecialcharsbx($sql);
				return false;
			}
			$sql = "";
		}
		mysql_query('SET FOREIGN_KEY_CHECKS = 1', $this->db_Conn);

		if($sql != "")
		{
			$result = @mysql_query($sql, $this->db_Conn);

			if(!$result)
			{
				$this->db_Error .= mysql_error().'<br><br>'.htmlspecialcharsbx($sql);
				return false;
			}
			$sql = "";
		}

		if ($this->LocalCloud && $this->f_end)
		{
			$i = '';
			while(file_exists($_SERVER['DOCUMENT_ROOT'].'/upload/'.($name = 'clouds'.$i)))
				$i++;
			if (!file_exists($f = $_SERVER['DOCUMENT_ROOT'].'/upload'))
				mkdir($f);
			if (rename($_SERVER['DOCUMENT_ROOT'].'/freetrix/backup/clouds', $_SERVER['DOCUMENT_ROOT'].'/upload/'.$name))
			{
				$arFiles = scandir($_SERVER['DOCUMENT_ROOT'].'/upload/'.$name);
				foreach($arFiles as $file)
				{
					if ($id = intval($file))
						mysql_query('UPDATE b_file SET SUBDIR = CONCAT("'.$name.'/'.$id.'/", SUBDIR), HANDLER_ID=NULL WHERE HANDLER_ID ='.$id);
				}
			}
		}
		return true;
	}
コード例 #4
0
ファイル: backup.php プロジェクト: ASDAFF/entask.ru
function CheckPoint()
{
	if (haveTime())
		return;
	
	global $NS;
	$NS['WORK_TIME'] = microtime(1) - START_TIME;
	session_write_close();
	echo "NEXT";
	exit(0);
}
コード例 #5
0
ファイル: backup.php プロジェクト: ASDAFF/bxApiDocs
	public function Scan($path)
	{
		$this->path = $path;

		if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path))
		{
			foreach($arCloudFiles['file'] as $k=>$file)
			{
				if ($this->last_bucket_path)
				{
					if ($path.'/'.$file == $this->last_bucket_path)
						$this->last_bucket_path = '';
					else
						continue;
				}

				$name = $this->path = $path.'/'.$file;
				if (!haveTime()) // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
					return false;

				$HTTP = new CHTTP;
				if ($HTTP->Download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT.BX_ROOT.'/backup/clouds/'.$this->id.$name))
				{
					$this->download_size += $arCloudFiles['file_size'][$k];
					$this->download_cnt++;
				}
				else
					$this->arSkipped[] = $name;
			}
		}

		foreach($arCloudFiles['dir'] as $dir)
		{
			if ($this->last_bucket_path)
			{
				if ($path.'/'.$dir == $this->last_bucket_path)
					$this->last_bucket_path = '';
				elseif (strpos($this->last_bucket_path, $path.'/'.$dir) !== 0)
					continue;
			}

			if ($path.'/'.$dir == '/bitrix/backup')
				continue;

			if ($path.'/'.$dir == '/tmp')
				continue;

			if (!$this->Scan($path.'/'.$dir)) // partial
				return false;
		}

		return true;
	}
コード例 #6
0
ファイル: restore.php プロジェクト: ASDAFF/entask.ru
	function ProcessFile($f)
	{
		if (!haveTime())
			return 'BREAK';
		global $a;
		if (!$a)
			return;
		$k = CTar::substr($f, $this->cut);
		if (!$a[$k])
		{
			$to = RESTORE_FILE_DIR.'/'.$k;
			CTar::xmkdir(dirname($to));
			rename($f, $to);
		}
		return true;
	}
コード例 #7
0
ファイル: backup.php プロジェクト: nProfessor/Mytb
	else
	{
		while($r = $tar->extractFile());
		if ($r === false)
			RaiseErrorAndDie(implode('<br>',$tar->err));
	}
	$tar->close();
}

if (IntOption('dump_send_to_bucket_id'))
{
	ShowBackupStatus('Sending backup to the cloud...');
	if (!CModule::IncludeModule('clouds'))
		RaiseErrorAndDie(GetMessage("MAIN_DUMP_NO_CLOUDS_MODULE"));

	while(haveTime())
	{
	xdebug_start_trace();
		$file_size = filesize($NS["arc_name"]);
		$obUpload = new CCloudStorageUpload(substr($NS['arc_name'],strlen(DOCUMENT_ROOT)));
		if (!$obUpload->isStarted())
		{
			if (!$obUpload->Start(IntOption('dump_send_to_bucket_id'), $file_size))
			{
				if ($e = $APPLICATION->GetException())
					$strError = $e->GetString();
				else
					$strError = GetMessage('MAIN_DUMP_INT_CLOUD_ERR');
				RaiseErrorAndDie($strError);
			}
		}