

# 从 RDS Custom for SQL Server 数据库快照还原
<a name="custom-backup-sqlserver.restoring"></a>

在还原 RDS Custom for SQL Server 数据库实例时，需要提供数据库快照的名称以及新实例的名称。您不能从快照还原到现有的 RDS Custom 数据库实例。还原时将新建一个 RDS Custom for SQL Server 数据库实例。

从快照还原会将存储卷还原到拍摄快照的时间点。这将包括 `(D:)` 卷上存在的所有数据库和任何其它文件。

## 控制台
<a name="custom-backup-sqlserver.restoring.console"></a>

**要从数据库快照还原 RDS Custom 数据库实例**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 在导航窗格中，选择**快照**。

1. 选择要从其还原的数据库快照。

1. 对于**操作**，选择**还原快照**。

1. 请在 **Restore DB instance**（还原数据库实例）页面上，为 **DB instance identifier**（数据库实例标识符）输入还原的 RDS Custom 数据库实例的名称。

1. 选择**还原数据库实例**。

## AWS CLI
<a name="custom-backup-sqlserver.restoring.CLI"></a>

您可以通过使用 [ restore-db-instance-from-db-snapshot](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-instance-from-db-snapshot.html) AWS CLI 命令还原 RDS Custom 数据库快照。

如果要从中还原的快照适用于私有数据库实例，请务必同时指定正确的 `db-subnet-group-name` 和 `no-publicly-accessible`。否则，数据库实例原定设置为可公开访问。以下选项为必填：
+ `db-snapshot-identifier` – 标识要从中进行还原的快照
+ `db-instance-identifier` – 指定要从数据库快照创建的 RDS Custom 数据库实例的名称
+ `custom-iam-instance-profile` – 指定与 RDS Custom 数据库实例的基础 Amazon EC2 实例关联的实例配置文件。

以下代码为 `my-custom-instance` 还原名为 `my-custom-snapshot` 的快照。

**Example**  
对于 Linux、macOS 或 Unix：  

```
aws rds restore-db-instance-from-db-snapshot \
  --db-snapshot-identifier my-custom-snapshot \
  --db-instance-identifier my-custom-instance \
  --custom-iam-instance-profile AWSRDSCustomInstanceProfileForRdsCustomInstance \
  --no-publicly-accessible
```
对于 Windows：  

```
aws rds restore-db-instance-from-db-snapshot ^
  --db-snapshot-identifier my-custom-snapshot ^
  --db-instance-identifier my-custom-instance ^
  --custom-iam-instance-profile AWSRDSCustomInstanceProfileForRdsCustomInstance ^
  --no-publicly-accessible
```