Ejemplo n.º 1
0
	<tr>
		<td><?=GetMessage('DISABLE_GZIP')?></td>
		<td><input type="checkbox" name="dump_disable_gzip" <?=IntOption('dump_use_compression') ? '' : 'checked' ?>>
	</tr>
	<tr>
		<td><?=GetMessage('INTEGRITY_CHECK_OPTION')?></td>
		<td><input type="checkbox" name="dump_integrity_check" <?=IntOption('dump_integrity_check') ? 'checked' : '' ?>>
	</tr>
	<tr>
		<td><?=GetMessage("MAIN_DUMP_MAX_ARCHIVE_SIZE")?></td>
		<td><input name="dump_archive_size_limit" value="<?=intval(COption::GetOptionString('main', 'dump_archive_size_limit', 1024 * 1024 * 1024)) / 1024 / 1024?>" size=4></td>
	</tr>

	<?$editTab->Buttons();
	?>
	<input type="button" id="start_button" value="<?=GetMessage("MAIN_DUMP_FILE_DUMP_BUTTON")?>" <?=!CBackup::CheckDumpFiles() && !CBackup::CheckDumpClouds() && !IntOption("dump_base") ? "disabled" : ''?> OnClick="StartDump();">
	<input type="button" id="stop_button" value="<?=GetMessage("MAIN_DUMP_FILE_STOP_BUTTON")?>" OnClick="EndDump();" disabled>

	<?
	$editTab->End();
	?>
	</form>

<?
$lAdmin->DisplayList();

echo BeginNote();
echo '<span class=required><sup>1</sup></span> '.GetMessage("MAIN_DUMP_FOOTER_MASK");
echo EndNote();

require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");
Ejemplo n.º 2
0
            $key .= '_' . $i;
            $arFiles[$key] = $ar;
        }
    }
}
if ($order == 'desc') {
    krsort($arFiles);
} else {
    ksort($arFiles);
}
$rsDirContent = new CDBResult();
$rsDirContent->InitFromArray($arFiles);
$rsDirContent->NavStart(20);
$lAdmin->NavText($rsDirContent->GetNavPrint(GetMessage("MAIN_DUMP_FILE_PAGES")));
$lAdmin->AddHeaders(array(array("id" => "NAME", "content" => GetMessage("MAIN_DUMP_FILE_NAME"), "sort" => "name", "default" => true), array("id" => "SIZE", "content" => GetMessage("MAIN_DUMP_FILE_SIZE1"), "sort" => "size", "default" => true), array("id" => "PLACE", "content" => GetMessage("MAIN_DUMP_LOCATION"), "sort" => "location", "default" => true), array("id" => "DATE", "content" => GetMessage('MAIN_DUMP_FILE_TIMESTAMP'), "sort" => "timestamp", "default" => true)));
$arWriteBucket = CBackup::GetBucketList($arFilter = array('READ_ONLY' => 'N'));
while ($f = $rsDirContent->NavNext(true, "f_")) {
    $BUCKET_ID = intval($f['BUCKET_ID']);
    $row =& $lAdmin->AddRow($BUCKET_ID . '_' . $f['NAME'], $f);
    $c = $arParts[$BUCKET_ID . $f['NAME']];
    if ($c > 1) {
        $parts = ' (' . GetMessage("MAIN_DUMP_PARTS") . $c . ')';
        $size = $arSize[$BUCKET_ID . $f['NAME']];
    } else {
        $parts = '';
        $size = $f['SIZE'];
    }
    $row->AddField("NAME", $f['NAME'] . $parts);
    $row->AddField("SIZE", CFile::FormatSize($size));
    $row->AddField("PLACE", $f['PLACE']);
    if ($f['DATE']) {
Ejemplo n.º 3
0
			<input type=button id="more_button" value="<?php 
echo GetMessage('MAIN_DUMP_MORE');
?>
" onclick="AddTableRow()">
		</td>
	</tr>
	<tr>
		<td><?php 
echo GetMessage("MAIN_DUMP_FILE_MAX_SIZE");
?>
</td>
		<td><input type="text" name="max_file_size" size="10" value="<?php 
echo IntOption("dump_max_file_size", 0);
?>
" <?php 
echo CBackup::CheckDumpFiles() ? '' : "disabled";
?>
>
		<?php 
echo GetMessage("MAIN_DUMP_FILE_MAX_SIZE_kb");
?>
</td>
	</tr>
	<tr>
		<td><?php 
echo GetMessage("MAIN_DUMP_SKIP_SYMLINKS");
?>
</td>
		<td><input type="checkbox" name="skip_symlinks" value="Y" <?php 
echo IntOption("skip_symlinks", 0) ? "checked" : '';
?>
Ejemplo n.º 4
0
				echo
				'<tr><td>
					<input type="text" name="arMask[]" id="mnu_FILES_'.$i.'" value="'.htmlspecialcharsbx($mask).'" size=30>'.
					'<input type="button" id="mnu_FILES_btn_'.$i.'" value="..." onclick="showMenu(this, \''.$i.'\')">'.
				'</tr>';
			}
			$i++;
			?>
				<tr><td><input type="text" name="arMask[]" id="mnu_FILES_<?=$i?>" size=30><input type="button" id="mnu_FILES_btn_<?=$i?>" value="..." onclick="showMenu(this, '<?=$i?>')"></tr>
			</table>
			<input type=button id="more_button" value="<?=GetMessage('MAIN_DUMP_MORE')?>" onclick="AddTableRow()">
		</td>
	</tr>
	<tr>
		<td><?echo GetMessage("MAIN_DUMP_FILE_MAX_SIZE")?></td>
		<td><input type="text" name="max_file_size" size="10" value="<?=IntOption("dump_max_file_size", 0)?>" <?=CBackup::CheckDumpFiles() ? '' : "disabled"?>>
		<?echo GetMessage("MAIN_DUMP_FILE_MAX_SIZE_kb")?></td>
	</tr>
	<tr>
		<td><?echo GetMessage("MAIN_DUMP_SKIP_SYMLINKS")?></td>
		<td><input type="checkbox" name="skip_symlinks" value="Y" <?=IntOption("skip_symlinks", 0) ? "checked" : ''?>></td>
	</tr>




	<tr class="heading">
		<td colspan="2"><?=GetMessage("DUMP_MAIN_ARC_MODE")?></td>
	</tr>
	<tr>
		<td><?=GetMessage("MAIN_DUMP_ENABLE_ENC")?><span class="required"><sup>4</sup></td>
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
		{
			$size = filesize($name);
			$NS['arc_size'] += $size;
			if ($arParams["disk_space"] > 0)
				CDiskQuota::updateDiskQuota("file", $size, "add");
			$name = CTar::getNextName($name);
		}
		$tar->close();
	}
	$NS['step'] = 3;
}

if ($NS['step'] == 3)
{
	// Download cloud files
	if ($arParams['dump_do_clouds'] && ($arDumpClouds = CBackup::GetBucketList()))
	{
		ShowBackupStatus('Downloading cloud files');
		foreach($arDumpClouds as $arBucket)
		{
			$id = $arBucket['ID'];
			if ($NS['bucket_finished_'.$id])
				continue;

			$obCloud = new CloudDownload($arBucket['ID']);
			$obCloud->last_bucket_path = $NS['last_bucket_path'];
			if ($res = $obCloud->Scan(''))
			{
				$NS['bucket_finished_'.$id] = true;
			}
			else
Ejemplo n.º 7
0
	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;
	}
Ejemplo n.º 8
0
    $tar->addFile($after_file);
    unlink($NS["dump_name"]) && (!file_exists($after_file) || unlink($after_file));
    $NS['arc_size'] = 0;
    $name = $NS["arc_name"];
    while (file_exists($name)) {
        $size = filesize($name);
        $NS['arc_size'] += $size;
        if ($arParams["disk_space"] > 0) {
            CDiskQuota::updateDiskQuota("file", $size, "add");
        }
        $name = CTar::getNextName($name);
    }
    $tar->close();
}
// Download cloud files
if ($arDumpClouds = CBackup::GetBucketList()) {
    ShowBackupStatus('Downloading cloud files');
    foreach ($arDumpClouds as $arBucket) {
        $obCloud = new CloudDownload($arBucket['ID']);
        $res = $obCloud->Scan('');
    }
}
$DB->Disconnect();
// Tar files
if (true) {
    ShowBackupStatus('Archiving files');
    $DOCUMENT_ROOT_SITE = DOCUMENT_ROOT;
    if (!defined('DOCUMENT_ROOT_SITE')) {
        define('DOCUMENT_ROOT_SITE', $DOCUMENT_ROOT_SITE);
    }
    $tar = new CTar();
Ejemplo n.º 9
0
 ShowBackupStatus('Archiving files');
 $DirScan = new CDirRealScan();
 $DirScan->startPath = $NS['startPath'];
 $tar = new CTar();
 $tar->EncryptKey = $NS['dump_encrypt_key'];
 $tar->ArchiveSizeLimit = $arParams['dump_archive_size_limit'];
 $tar->gzip = $arParams['dump_use_compression'];
 $tar->ReadBlockCurrent = intval($NS['ReadBlockCurrent']);
 $tar->ReadFileSize = intval($NS['ReadFileSize']);
 foreach ($NS['site_path_list'] as $SITE_ID => $DOCUMENT_ROOT_SITE) {
     $tar->path = $DOCUMENT_ROOT_SITE;
     if (!$tar->openWrite($NS["arc_name"])) {
         RaiseErrorAndDie(GetMessage('DUMP_NO_PERMS'), 400, $NS['arc_name']);
     }
     CBackup::$DOCUMENT_ROOT_SITE = $DOCUMENT_ROOT_SITE;
     CBackup::$REAL_DOCUMENT_ROOT_SITE = realpath($DOCUMENT_ROOT_SITE);
     if ($NS['multisite']) {
         $tar->prefix = 'bitrix/backup/sites/' . $SITE_ID . '/';
         $DirScan->arSkip[rtrim($DOCUMENT_ROOT_SITE, '/') . '/bitrix'] = true;
         $DirScan->arSkip[rtrim($DOCUMENT_ROOT_SITE, '/') . '/upload'] = true;
     }
     $Block = $tar->Block;
     $r = $DirScan->Scan($DOCUMENT_ROOT_SITE);
     $tar->close();
     $NS["data_size"] += 512 * ($tar->Block - $Block);
     if ($r === false) {
         RaiseErrorAndDie(implode('<br>', array_merge($tar->err, $DirScan->err)), 410);
     }
     $NS["ReadBlockCurrent"] = $tar->ReadBlockCurrent;
     $NS["ReadFileSize"] = $tar->ReadFileSize;
     $NS["startPath"] = $DirScan->nextPath;
Ejemplo n.º 10
0
	$tar->close();
}

if ($arDumpClouds = CBackup::CheckDumpClouds())
{
	ShowBackupStatus('Downloading cloud files...');
	foreach($arDumpClouds as $arBucket)
	{
		$id = $arBucket['ID'];

		$obCloud = new CloudDownload($id);
		$res = $obCloud->Scan('');
	}
}

if (CBackup::CheckDumpFiles() || CBackup::CheckDumpClouds())
{
	ShowBackupStatus('Archiving files...');
	$DOCUMENT_ROOT_SITE = DOCUMENT_ROOT;
	if (!defined('DOCUMENT_ROOT_SITE'))
		define('DOCUMENT_ROOT_SITE', $DOCUMENT_ROOT_SITE);

	$tar = new CTar;
	$tar->EncryptKey = $arParams['dump_encrypt_key'];
	$tar->ArchiveSizeLimit = IntOption('dump_archive_size_limit');
	$tar->gzip = IntOption('dump_use_compression');
	$tar->path = DOCUMENT_ROOT_SITE;

	if (!$tar->openWrite($NS["arc_name"]))
		RaiseErrorAndDie(GetMessage('DUMP_NO_PERMS'));