{"id":54,"date":"2017-11-01T08:00:01","date_gmt":"2017-10-31T23:00:01","guid":{"rendered":"http:\/\/www.itc109.com\/knowledge\/?p=54"},"modified":"2021-09-30T09:00:54","modified_gmt":"2021-09-30T00:00:54","slug":"aws-ebs-snapshot-generation","status":"publish","type":"post","link":"https:\/\/www.itc109.com\/knowledge\/aws\/aws-ebs-snapshot-generation","title":{"rendered":"AWS EBS &#8211; \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u81ea\u52d5\u53d6\u5f97\uff06\u4e16\u4ee3\u7ba1\u7406"},"content":{"rendered":"<h4><strong>\u6982\u8981<\/strong><\/h4>\n<hr \/>\n<p>AWS EBS\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u300c\u81ea\u52d5\u53d6\u5f97\u300d\u3068\u300c\u6307\u5b9a\u306e\u4e16\u4ee3\u307e\u3067\u306e\u7ba1\u7406\u300d\u3092\u5b9f\u65bd\u3067\u304d\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>\u624b\u9806<\/strong><\/h4>\n<hr \/>\n<ul>\n<li>\u30bf\u30b0\u306e\u8a2d\u5b9a<\/li>\n<li>\u95a2\u6570\u306e\u4f5c\u6210<\/li>\n<li>\u30c6\u30b9\u30c8\u30fb\u78ba\u8a8d<\/li>\n<li>\u88dc\u8db3<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h5><strong>\u30bf\u30b0\u306e\u8a2d\u5b9a<\/strong><\/h5>\n<hr \/>\n<p><strong>1.\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u300c\u540d\u524d\u300d\u3068\u300c\u4e16\u4ee3\u7ba1\u7406\u7528\u300d\u306e\u30bf\u30b0\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">1-1.[ EC2 &gt; \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 &gt; \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 ] \u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-729\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-01.png\" alt=\"\" width=\"369\" height=\"291\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-2.\u300e\u30bf\u30b0\u300f\u30bf\u30d6\u3092\u8868\u793a\u3057\u3010 \u30bf\u30b0\u306e\u8ffd\u52a0\/\u7de8\u96c6 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-730\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-02.png\" alt=\"\" width=\"426\" height=\"189\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-3.\u8868\u793a\u3055\u308c\u305f\u300e\u30bf\u30b0\u306e\u8ffd\u52a0\/\u7de8\u96c6\u300f\u753b\u9762\u3067\u3010 \u30bf\u30b0\u306e\u4f5c\u6210 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u884c\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-731\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-1-03.png\" alt=\"\" width=\"602\" height=\"358\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-4.\u9069\u5f53\u306a\u5024\u3092\u5165\u529b\u3057\u3066\u3010 \u4fdd\u5b58 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<table style=\"margin-left: 30px;\">\n<tbody style=\"padding-left: 30px;\">\n<tr style=\"padding-left: 30px;\">\n<th>\u30ad\u30fc<\/th>\n<th>\u5024<\/th>\n<\/tr>\n<tr>\n<td>Name<\/td>\n<td>\u203b\u9069\u5f53\u306a\u540d\u524d\u5165\u529b<\/td>\n<\/tr>\n<tr>\n<td>Backup-Generation<\/td>\n<td>2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"padding-left: 30px;\">\u203b\u300cBackup-Generation\u300d\u30ad\u30fc\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u5024\u304c\u300c\u4e16\u4ee3\u7ba1\u7406\u300d\u6570\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h5><strong>\u95a2\u6570\u306e\u4f5c\u6210<\/strong><\/h5>\n<hr \/>\n<p><strong>1.Lambda\u3067\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">1-1.[ Lambda ]\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-2.\u3010 \u95a2\u6570\u306e\u4f5c\u6210 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-732\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-01.png\" alt=\"\" width=\"1920\" height=\"970\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.\u8a2d\u8a08\u56f3\u306e\u9078\u629e\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">2-1.[ lambda-canary ]\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-733\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-02.png\" alt=\"\" width=\"1920\" height=\"996\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">2-2.\u8868\u793a\u3055\u308c\u305f[ lambda-canary ]\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-734\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/aws\/snapshot\/auto-snapshot-2-03.png\" alt=\"\" width=\"409\" height=\"152\" border=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.\u300c\u57fa\u672c\u7684\u306a\u60c5\u5831\u300d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">3-1.\u300e\u540d\u524d\u300f\u3092\u5165\u529b\u3057\u3001\u300e\u30ed\u30fc\u30eb\u300f\u304b\u3089 [ \u30ab\u30b9\u30bf\u30e0\u30ed\u30fc\u30eb\u306e\u4f5c\u6210 ] \u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-140\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-04.png\" alt=\"\" width=\"1001\" height=\"389\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: left; padding-left: 30px;\">3-2.\u300e\u30ed\u30fc\u30eb\u306e\u4f5c\u6210\u300f\u30bf\u30d6\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-141\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-05.png\" alt=\"\" width=\"1920\" height=\"941\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">3-3.\u300e\u30ed\u30fc\u30eb\u540d\u300f\u306b\u5024\u3092\u5165\u529b\u3057\u3001\u30dd\u30ea\u30b7\u30fc\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u3010 \u7de8\u96c6 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-142\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-06.png\" alt=\"\" width=\"1920\" height=\"941\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">3-4.\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u3010 OK \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-146\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-07.png\" alt=\"\" width=\"392\" height=\"162\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">3-5.\u30dd\u30ea\u30b7\u30fc\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u7de8\u96c6\u53ef\u80fd\u3068\u306a\u3063\u305f\u3089\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306b\u5dee\u3057\u66ff\u3048\u5f8c\u3001\u3010 \u8a31\u53ef \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n{\r\n    \"Version\": \"2012-10-17\",\r\n    \"Statement\": [\r\n        {\r\n            \"Effect\": \"Allow\",\r\n            \"Action\": [\r\n                \"logs:CreateLogGroup\",\r\n                \"logs:CreateLogStream\",\r\n                \"logs:PutLogEvents\"\r\n            ],\r\n            \"Resource\": [\r\n                \"arn:aws:logs:*:*:*\"\r\n            ]\r\n        },\r\n        {\r\n            \"Effect\": \"Allow\",\r\n            \"Action\": [\r\n                \"ec2:DescribeInstances\",\r\n                \"ec2:DescribeSnapshots\",\r\n                \"ec2:CreateSnapshot\",\r\n                \"ec2:DeleteSnapshot\"\r\n            ],\r\n            \"Resource\": [\r\n                \"*\"\r\n            ]\r\n        }\r\n    ]\r\n}\r\n\r\n\r\n<\/pre>\n<p style=\"padding-left: 30px;\">\u300eLambda\u300f\u753b\u9762\u306b\u623b\u308a\u3001\u65e2\u5b58\u306e\u30ed\u30fc\u30eb\u306b\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30ed\u30fc\u30eb\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-147\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-08.png\" alt=\"\" width=\"1001\" height=\"388\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>4.\u300ccloudwatch-events\u300d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<h4 style=\"padding-left: 30px;\"><strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-148\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-09.png\" alt=\"\" width=\"1001\" height=\"639\" border=\"1\" \/><\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">4-1.\u4ee5\u4e0b\u306e\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-137\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-10.png\" alt=\"\" width=\"1000\" height=\"865\" border=\"1\" \/><\/p>\n<table style=\"margin-left: 30px;\" border=\"0\">\n<tbody>\n<tr>\n<td>\u30eb\u30fc\u30eb<\/td>\n<td>\u65b0\u898f\u30eb\u30fc\u30eb\u306e\u4f5c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u30eb\u30fc\u30eb\u540d<\/td>\n<td>snapshot<\/td>\n<\/tr>\n<tr>\n<td>\u30eb\u30fc\u30eb\u306e\u8aac\u660e<\/td>\n<td>\u203b\u4efb\u610f<\/td>\n<\/tr>\n<tr>\n<td>\u30eb\u30fc\u30eb\u30bf\u30a4\u30d7<\/td>\n<td>\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u5f0f<\/td>\n<td>cron(0 15 * * ? *)<\/td>\n<\/tr>\n<tr>\n<td>\u30c8\u30ea\u30ac\u30fc\u306e\u6709\u52b9\u5316<\/td>\n<td>\u6709\u52b9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"padding-left: 30px;\"><span style=\"color: #ff0000;\">\u203b\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u5f0f\uff1a\u65e5\u672c\u6642\u9593 00:00 \u306b\u5b9f\u884c<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>5.\u300cLambda\u95a2\u6570\u30b3\u30fc\u30c9\u300d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-138\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-11.png\" alt=\"\" width=\"1000\" height=\"1083\" border=\"1\" \/><\/p>\n<table style=\"margin-left: 30px;\">\n<tbody>\n<tr>\n<td>\u74b0\u5883\u5909\u6570<\/td>\n<td>\u203b\u672a\u69cb\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u4fdd\u7ba1\u6642\u306b\u6697\u53f7\u5316\u3059\u308bKMS\u30ad\u30fc<\/td>\n<td>(\u30c7\u30d5\u30a9\u30eb\u30c8)aws\/lambda<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"padding-left: 30px;\"><span style=\"color: #ff0000;\">\u203b\u74b0\u5883\u5909\u6570\u3092\u3059\u3079\u3066\u524a\u9664\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">\u3010 \u95a2\u6570\u306e\u4f5c\u6210 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<h4 style=\"padding-left: 30px;\"><strong> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-151\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-12.png\" alt=\"\" width=\"1033\" height=\"534\" border=\"1\" \/><\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p><strong>7.\u95a2\u6570\u30b3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">7-1.\u300c\u8a2d\u5b9a\u300d\u30bf\u30d6\u3092\u9078\u629e\u3057\u3001\u95a2\u6570\u30b3\u30fc\u30c9\u3092\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3068\u5dee\u3057\u66ff\u3048\u3066\u3010 \u4fdd\u5b58 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<h4 style=\"padding-left: 30px;\"><strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-158\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-20.png\" alt=\"\" width=\"1088\" height=\"866\" border=\"1\" \/><\/strong><\/h4>\n<pre>\r\n\r\nimport boto3\r\nimport collections\r\nimport time\r\nfrom botocore.client import ClientError\r\n\r\nec2 = boto3.client('ec2')\r\n\r\n\r\ndef lambda_handler(event, context):\r\n    descriptions = create_snapshots()\r\n    delete_old_snapshots(descriptions)\r\n\r\n\r\ndef create_snapshots():\r\n    instances = get_instances(['Backup-Generation'])\r\n\r\n    descriptions = {}\r\n\r\n    for i in instances:\r\n        tags = {t['Key']: t['Value'] for t in i['Tags']}\r\n        generation = int(tags.get('Backup-Generation', 0))\r\n\r\n        if generation < 1:\r\n            continue\r\n\r\n        for b in i['BlockDeviceMappings']:\r\n            if b.get('Ebs') is None:\r\n                continue\r\n\r\n            volume_id = b['Ebs']['VolumeId']\r\n            description = volume_id if tags.get('Name') is '' else '%s(%s)' % (volume_id, tags['Name'])\r\n            description = 'Auto Snapshot ' + description\r\n\r\n            snapshot = _create_snapshot(volume_id, description)\r\n            print 'create snapshot %s(%s)' % (snapshot['SnapshotId'], description)\r\n\r\n            descriptions[description] = generation\r\n\r\n    return descriptions\r\n\r\n\r\ndef get_instances(tag_names):\r\n    reservations = ec2.describe_instances(\r\n        Filters=[\r\n            {\r\n                'Name': 'tag-key',\r\n                'Values': tag_names\r\n            }\r\n        ]\r\n    )['Reservations']\r\n\r\n    return sum([\r\n        [i for i in r['Instances']]\r\n        for r in reservations\r\n    ], [])\r\n\r\n\r\ndef delete_old_snapshots(descriptions):\r\n    snapshots_descriptions = get_snapshots_descriptions(descriptions.keys())\r\n\r\n    for description, snapshots in snapshots_descriptions.items():\r\n        delete_count = len(snapshots) - descriptions[description]\r\n\r\n        if delete_count <= 0:\r\n            continue\r\n\r\n        snapshots.sort(key=lambda x: x['StartTime'])\r\n\r\n        old_snapshots = snapshots[0:delete_count]\r\n\r\n        for s in old_snapshots:\r\n            _delete_snapshot(s['SnapshotId'])\r\n            print 'delete snapshot %s(%s)' % (s['SnapshotId'], s['Description'])\r\n\r\n\r\ndef get_snapshots_descriptions(descriptions):\r\n    snapshots = ec2.describe_snapshots(\r\n        Filters=[\r\n            {\r\n                'Name': 'description',\r\n                'Values': descriptions,\r\n            }\r\n        ]\r\n    )['Snapshots']\r\n\r\n    groups = collections.defaultdict(lambda: [])\r\n    {groups[s['Description']].append(s) for s in snapshots}\r\n\r\n    return groups\r\n\r\n\r\ndef _create_snapshot(id, description):\r\n    for i in range(1, 3):\r\n        try:\r\n            return ec2.create_snapshot(VolumeId=id, Description=description)\r\n        except ClientError as e:\r\n            print str(e)\r\n        time.sleep(1)\r\n    raise Exception('cannot create snapshot ' + description)\r\n\r\n\r\ndef _delete_snapshot(id):\r\n    for i in range(1, 3):\r\n        try:\r\n            return ec2.delete_snapshot(SnapshotId=id)\r\n        except ClientError as e:\r\n            print str(e)\r\n        time.sleep(1)\r\n    raise Exception('cannot delete snapshot ' + id)\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5><strong>\u30c6\u30b9\u30c8\u30fb\u78ba\u8a8d<\/strong><\/h5>\n<hr \/>\n<p><strong>1.\u30c6\u30b9\u30c8\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">1-1.\u300c\u30c6\u30b9\u30c8\u30a4\u30d9\u30f3\u30c8\u306e\u8a2d\u5b9a\u300d\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-152\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-13.png\" alt=\"\" width=\"317\" height=\"81\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-2.\u30c6\u30b9\u30c8\u30a4\u30d9\u30f3\u30c8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-153\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-14.png\" alt=\"\" width=\"820\" height=\"532\" \/><\/p>\n<p style=\"padding-left: 30px;\">1-3.\u300c\u30a4\u30d9\u30f3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u300d\u30ea\u30b9\u30c8\u304b\u3089 [ Schedule Event ] \u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-154\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-15.png\" alt=\"\" width=\"566\" height=\"389\" border=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-4.\u30a4\u30d9\u30f3\u30c8\u540d\u3092\u5165\u529b\u3057\u3066\u3010 \u4f5c\u6210 \u3011\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-155\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-16.png\" alt=\"\" width=\"819\" height=\"563\" border=\"1\" \/><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #ff0000;\">\u203b\u30b3\u30fc\u30c9\u306f\u305d\u306e\u307e\u307e<\/span><\/p>\n<pre><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">1-5. \u4f5c\u6210\u3057\u305f\u30a4\u30d9\u30f3\u30c8\u3092\u9078\u629e\u3057\u3066\u30c6\u30b9\u30c8 \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-156 alignnone\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-18.png\" alt=\"\" width=\"331\" height=\"68\" \/><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #ff0000;\">\u203b\u300e \u5b9f\u884c\u7d50\u679c \u300f\u304c\u3010 \u6210\u529f \u3011\u3068\u8868\u793a\u3055\u308c\u308b\u4e8b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p style=\"padding-left: 30px;\">2-1.\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u4e8b\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-159\" src=\"http:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/auto-snapshot-2-21.png\" alt=\"\" width=\"1150\" height=\"256\" border=\"1\" \/><\/p>\n<p style=\"padding-left: 30px;\">2-2.\u4e16\u4ee3\u7ba1\u7406\u306e\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 30px;\">\u30c6\u30b9\u30c8\u3092\u8907\u6570\u56de\u5b9f\u884c\u3057\u3001\u30bf\u30b0\u300cBackup-Generation\u300d\u3067\u8a2d\u5b9a\u3057\u305f\u5024\u306e\u307f\u6700\u65b0\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u4e8b\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>\u88dc\u8db3<\/strong><\/h4>\n<hr \/>\n<p>CloudWatch\u3067\u30a2\u30e9\u30fc\u30e0\u3092\u8a2d\u5b9a\u3059\u308b\u4e8b\u3067\u3001\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306b\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.itc109.com\/knowledge\/?p=87&#038;preview=true\" target=\"_blank\" rel=\"noopener\">AWS CloudWatch - \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210\u5931\u6557\u6642\u306b\u30a2\u30e9\u30fc\u30c8\u9001\u4fe1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 AWS EBS\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u300c\u81ea\u52d5\u53d6\u5f97\u300d\u3068\u300c\u6307\u5b9a\u306e\u4e16\u4ee3\u307e\u3067\u306e\u7ba1\u7406\u300d\u3092\u5b9f\u65bd\u3067\u304d\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002 &nbsp; \u624b\u9806 \u30bf\u30b0\u306e\u8a2d\u5b9a \u95a2\u6570\u306e\u4f5c\u6210 \u30c6\u30b9\u30c8\u30fb\u78ba\u8a8d \u88dc\u8db3 &nbsp; \u30bf\u30b0\u306e\u8a2d\u5b9a 1.\u30a4\u30f3\u30b9&#8230;<\/p>\n","protected":false},"author":3,"featured_media":23,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[59],"class_list":["post-54","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","tag-snapshot"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/logo\/logo-aws.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pacZwp-S","_links":{"self":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":18,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":1816,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/54\/revisions\/1816"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media\/23"}],"wp:attachment":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}