【问题标题】:Transfer Files from Rackspace CloudSite to Cloud Files将文件从 Rackspace CloudSite 传输到云文件
【发布时间】:2012-11-15 22:03:26
【问题描述】:

只是想知道是否有人知道用于将文件从机架空间云站点传输到机架空间云文件的预先编写的 php 脚本。

Rackspace 确实提供了一个脚本来备份 文件到云端,但不提供传输。 (我花了几个小时才意识到这一点,终于让脚本工作了)。

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

我不知道 PHP(这是 Rackspace cron 作业所必需的),所以如果有一个脚本可以帮助我解决这个问题,那就太好了。

谢谢。

【问题讨论】:

  • 如何转帐?为什么?你不能简单地手动转移它们吗?
  • @relentless 我们有数万个文件,下载和重新上传需要几天时间:/ 我们需要将它们直接从服务器移动/复制到云端。
  • 不确定您的问题。看起来您说您已备份到云文件,并且希望将备份放在您已启动的云服务器上。如果是这样,只需将备份文件从云文件下载到服务器并使用标准 Linux 命令解压缩即可。

标签: php rackspace-cloud rackspace


【解决方案1】:

以下是我备份到 rackspace 时使用的脚本。它使用来自 racker labs 的 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);
 }

}

?>

【讨论】:

    猜你喜欢
    • 2011-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多