2012-11-15 66 views
0

想知道是否有人知道預先編寫的php腳本來將文件從rackspace雲站點傳輸到rackspace雲文件。將文件從Rackspace CloudSite傳輸到雲文件

Rackspace確實提供了一個腳本備份文件到雲但不是轉移。 (我只是在花了幾個小時才發現腳本工作後才意識到)。

http://www.rackspace.com/knowledge_center/article/how-to-use-cron-to-backup-cloudsites-to-cloudfiles

我不知道PHP(這是需要Rackspace公司cron作業),所以如果有一個腳本,會幫我這將是巨大的。

謝謝。

+0

轉移怎麼樣?爲什麼?你不能簡單地手動轉移它們嗎? –

+0

@relentless我們有數以萬計的文件,下載和重新上傳需要幾天時間:/我們需要將它們直接從服務器移動/複製到雲端。 – Rivka

+0

不確定你的問題。它看起來像你說你做了雲文件的備份,並希望將備份放到你已經啓動的雲服務器上。如果是這樣,那麼只需將備份文件從雲文件下載到服務器並使用標準Linux命令解壓即可。 –

回答

0

下面是我備份到rackspace時使用的腳本。它使用來自racker實驗室的php雲文件主庫。我把它設置爲一個簡單的cron。只需更換鄂麥

php 'path/to/backup.php' 

<? 

require_once('php-cloudfiles-master/cloudfiles.php'); 

$server_name = 'YOUR_SERVER_NAME'; //Name of the Current Server 
$curr_date_time = date("Y-m-d--H:i:s"); //DON' CHANGE - Date 
$curr_day = date("Yd"); //DON' CHANGE - Date 
$sites = array("ENTERDATABASES HERE IN ARRAY FORMAT"); //Array of Databases to be Backed up 
$site_root = "/var/www/"; 
$temp_dir = "/bak/mysql/"; //temp directory 
$site_temp_dir = "/bak/site/"; //temp directory 
$rscfUsername = 'YOUR RACKSPACE USERNAME'; // the username for your rackspace account 
$rscfApiKey = 'YOUR RACKSPACE API KEY'; // the api key for your account 
$rscfContainer = 'YOUR RACKSPACE CONTAINER'; //rackspace containr 
foreach($sites as $site) { 

try{ 

exec("tar -czpf {$site_temp_dir}{$site}{$curr_date_time}_site.tar.gz {$site_root}{$site}"); 
// check if the file is created 
if(file_exists("{$site_temp_dir}{$site}{$curr_date_time}_site.tar.gz")) { 

$auth = new CF_Authentication($rscfUsername, $rscfApiKey); 
$auth->ssl_use_cabundle(); 
$auth->authenticate(); 
$conn = new CF_Connection($auth); 
$conn->ssl_use_cabundle(); 

// I allready created a container with this name otherwise user create_container 
$container = $conn->get_container($rscfContainer); 

// make a unique name with date in it so you know when it was created 
$objectName = $site.$curr_date_time.'.tar.gz'; 
$store = $container->create_object($objectName); 
$store->load_from_filename("{$site_temp_dir}{$site}{$curr_date_time}_site.tar.gz"); // send to rackspace 


} 

} catch (Exception $e) { 
    print_r($e, true); 
} 

} 

?> 
相關問題