使用 CLI 或 PowerShell 手动拍摄现有数据库的快照,并记下 DBSnapshotIdentifier。
使用 PowerShell 它看起来像这样:
New-RDSDBSnapshot -DBSnapshotIdentifier "NameOfYourNewSnapshot" -DBInstanceIdentifier "YourExistingDbIdentifier"
好的,现在您有了快照,您需要更改 CloudFormation 模板以使用 DBSnapshotIdentifier。
更改现有模板以创建 SqlServer 数据库并指定新属性DBSnapshotIdentifier
:
"MyDB" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBSecurityGroups" : [
{"Ref" : "MyDbSecurityByEC2SecurityGroup"}, {"Ref" : "MyDbSecurityByCIDRIPGroup"} ],
"AllocatedStorage" : "20",
"DBInstanceClass" : "db.t2.micro",
"Engine" : "sqlserver-ex",
"MasterUsername" : "MyName",
"MasterUserPassword" : "MyPassword",
"DBSnapshotIdentifier" : "NameOfYourNewSnapshot"
}
}
应该就是这样,当您运行堆栈时,它会从您的快照中删除并重新创建您的数据库,因此请务必注意停机时间。
文件:
http://docs.aws.amazon.com/powershell/latest/reference/Index.html
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-dbsnapshotidentifier