方法一:使用 Image 方式
EC2 Console > Snapshots > 指定要復原的 snapshot > Create Image >
EC2 Console > AMIs > 選擇剛剛新增的 AMI > Launch, 建立一個新的 Instance
以 EC2 API 方式對 Instance 定期作 snapshot,並只保持最新期間的備份檔。
作者網站:http://tiger-fish.com/blog/automated...ing-amazon-ec2
專案首頁:http://code.google.com/p/ec2-delete-old-snapshots/
主要的 EC2 API Script 有兩個:
PHP 版本建議是 5.2+
Cron Script:
#!/bin/bash DATESTAMP=`date +%Y%m%d` TIMESTAMP=`date +%H%M` LOGFILE="/var/log/tigerfish_ebs_backup.log" VOLUMES=( vol-12345678 vol-23456789 vol-34567890 ) echo "TIGERFISH EBS BACKUP $DATESTAMP $TIMESTAMP" 2>&1 | tee -a $LOGFILE echo " " 2>&1 | tee -a $LOGFILE # Create a snapshot of each volume. for volume in ${VOLUMES[@]} do php CreateSnapshot.php -v $volume 2>&1 | tee -a $LOGFILE done # Remove older snapshots we don't need to keep any more. for volume in ${VOLUMES[@]} do php ec2-manage-snapshots.php -v $volume 2>&1 | tee -a $LOGFILE done
CreateSnapshot.php
$ec2Config = array ('ServiceURL' => 'https://eu-west-1.ec2.amazonaws.com'); $service = new Amazon_EC2_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, $ec2Config);
ec2-manage-snapshots.php
Images 0 | ||
---|---|---|
No images to display in the gallery. |