イベントサブスクリプション
RDS のスナップショット作成はイベントサブスクリプションで通知することができる。
Amazon RDS イベント通知の使用 - Amazon Relational Database Service
カテゴリ RDS イベント ID 説明 作成 RDS-EVENT-0042 手動 DB スナップショットが作成されました。
- スナップショット取得時のメール
Event Source : db-cluster-snapshot Identifier Link: https://console.aws.amazon.com/rds/home?region=ap-northeast-1#snapshot:engine=aurora;id=aurora-postgres107-instance-1-20191010-4 SourceId: aurora-postgres107-instance-1-20191010-4 Notification time : 2019-10-09 23:50:11.804 Message : Creating manual cluster snapshot Event ID : http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/USER_Events.html#RDS-EVENT-0074
- スナップショット取得完了時のメール
Event Source : db-cluster-snapshot Identifier Link: https://console.aws.amazon.com/rds/home?region=ap-northeast-1#snapshot:engine=aurora;id=aurora-postgres107-instance-1-20191010-4 SourceId: aurora-postgres107-instance-1-20191010-4 Notification time : 2019-10-09 23:51:14.101 Message : Manual cluster snapshot created Event ID : http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/USER_Events.html#RDS-EVENT-0075
AWS CLI で確認
- Aurora PostgreSQL互換のスナップショットを取得する。まずは API 発行が成功していることを確認。
$ aws rds create-db-cluster-snapshot --db-cluster-identifier aurora-postgres107 --db-cluster-snapshot-identifier aurora-postgres107-instance-1-20191010-1 { "DBClusterSnapshot": { "Engine": "aurora-postgresql", "SnapshotCreateTime": "2019-10-09T23:26:38.531Z", "VpcId": "vpc-e...", "DBClusterIdentifier": "aurora-postgres107", "DBClusterSnapshotArn": "arn:aws:rds:ap-northeast-1:1234567890123:cluster-snapshot:aurora-postgres107-instance-1-20191010-1", "MasterUsername": "awsuser", "LicenseModel": "postgresql-license", "Status": "creating", "PercentProgress": 0, "DBClusterSnapshotIdentifier": "aurora-postgres107-instance-1-20191010-1", "KmsKeyId": "arn:aws:kms:ap-northeast-1:1234567890123:key/2ebae6df-2bf5-****-****-********996", "ClusterCreateTime": "2019-09-15T18:37:32.844Z", "StorageEncrypted": true, "AllocatedStorage": 1, "EngineVersion": "10.7", "SnapshotType": "manual", "AvailabilityZones": [ "ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d" ], "IAMDatabaseAuthenticationEnabled": false, "Port": 0 } }
- スナップショット取得成功を確認する。
$ aws rds describe-db-cluster-snapshots --db-cluster-identifier aurora-postgres107 --db-cluster-snapshot-identifier aurora-postgres107-instance-1-20191010-1|jq -r '.DBClusterSnapshots[]|@text "\(.DBClusterSnapshotIdentifier)\t\(.SnapshotCreateTime)\t\(.Status)\t\(.PercentProgress)"' aurora-postgres107-instance-1-20191010-1 2019-10-09T23:26:38.531Z creating 0 ★作成中 $ aws rds describe-db-cluster-snapshots --db-cluster-identifier aurora-postgres107 --db-cluster-snapshot-identifier aurora-postgres107-instance-1-20191010-1|jq -r '.DBClusterSnapshots[]|@text "\(.DBClusterSnapshotIdentifier)\t\(.SnapshotCreateTime)\t\(.Status)\t\(.PercentProgress)"' aurora-postgres107-instance-1-20191010-1 2019-10-09T23:26:38.531Z available 100 ★完了