我正在處理將所有zpanel備份上傳到我的Amazon S3帳戶的腳本。如果我不使用zpanel備份,並使用CronJob創建和上傳由我創建的備份,它就可以工作。移動Zpanel默認備份目錄或Opendir備份目錄
我無法上傳zpanel備份的原因是我找不到使用php opendir函數訪問「備份」目錄的方法。
我知道備份文件夾的絕對路徑。並且當它看來,這絕對路徑不會opendir()
工作,我用:opendir('var/zpanel/hostdata/my_username/backups/')
而且它不會工作。現在,如果我想使用相對路徑,我也無法到達那裏。
那麼,有沒有一種方法可以將zPanel Backups目錄移動到public_html文件夾內的某處?或者,可以訪問備份文件夾的網址? Ajaxplorer可以到達那裏,爲什麼我不能?
如果沒有可能的話,我會非常感謝,如果有人能教我創建像zPanel一樣的備份(所有DB + public_html文件夾中的所有內容)。
的代碼看起來像這樣
require_once('S3.php');
// Enter your amazon s3 creadentials
$s3 = new S3('xxxxx', 'xxxxx');
if ($handle = opendir('var/zpanel/hostdata/my_username/backups/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
//echo "okay";
echo $file; exit;
if ($s3->putObjectFile("backups/$file", "my_basket", "$file", S3::ACL_PUBLIC_READ)) {
echo "<strong>We successfully uploaded your file.<br /></strong>";
//this will delete the file from your server after upload
//if (file_exists($baseurl . '/' . $file)) { unlink ($baseurl . '/' . $file); }
}else{
echo "<strong>Something went wrong while uploading your file... sorry.</strong>";
}
}else{
echo "No file found here ".$root;
}
}
closedir($handle);
}
非常感謝提前!