2015-04-05 23 views
0

我想使用Phar Class Php 5.3+給我,但我有一個問題,我的網站備份。我不想將以前的備份包含到我的備份文件中,因此我想排除$skip = "BackUp*.tar";,但我找不到一種方法來製作它。基本上我的腳本在這裏:使用phar類備份完整的網站在php中排除一些文件

<?php 
$root = realpath($_SERVER['DOCUMENT_ROOT']); // the website root 
$sdir = realpath($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF'])); // the directory where this script is stored 
$name = "BackUp_" . date("[d-m-Y][H-i-s]") . ".tar"; // name of the archive 
$skip = "BackUp*.tar"; // files to skip/exclude from backup 
$phar = new PharData($name); // create new call 
$phar->buildFromDirectory($root); // create a tar file from root with all files/dirs 
?> 

有沒有辦法讓它變得簡單?

回答

0

您可以使用Phar::buildFromIterator然後使用RecursiveFilterIterator過濾掉這些文件。 在那裏你可以定義自己的匹配方法來過濾掉文件。

+0

可以排除'$ sdir/$ skip'?你能舉個例子嗎?對我來說這是一個新課,直到現在我還沒有幸運地用Google搜索。 – Alessandro 2015-04-14 06:07:01

相關問題