Beispiel #1
0
 * if you really need to back-up all of your servers you can create back-up
 * schedule using addBackupSchedule() method.
 *
 * @author Aleksey Korzun <*****@*****.**>
 * @link http://github.com/AlekseyKorzun/php-cloudservers/
 * @link http://www.schematic.com
 */
include '../Cloud/Exception.php';
// Provide your API ID (username) and API KEY (generated by Rackspace)
DEFINE('API_ID', '');
DEFINE('API_KEY', '');
try {
    // Initialize connection
    $cloud = new Cloud_Server(API_ID, API_KEY);
    // Retrieve all of available servers
    $servers = $cloud->getServers();
    // If list of servers was successfully retrieved we should now have an array
    // of servers that we can loop throught and create back-up images
    if (is_array($servers) && !empty($servers)) {
        foreach ($servers as $serverId => $server) {
            // Create back-up images
            if (!$cloud->createImage('Back up for: ' . $server['name'], $serverId)) {
                print 'Failed to back up server #: ' . $serverId;
            }
        }
    }
    // Get all of created back-up images
    print_r($cloud->getImages());
} catch (Cloud_Exception $e) {
    print $e->getMessage();
}