

# 共享数据库集群快照
<a name="aurora-share-snapshot"></a>

使用 Amazon RDS，您可以按以下方式共享手动数据库集群快照：
+ 共享手动数据库集群快照（无论是否加密）可允许经授权的 Amazon 账户复制快照。
+ 共享手动数据库集群快照（无论是否加密）可允许经授权的 Amazon 账户直接从快照还原数据库集群，无需复制数据库集群再从中进行还原。

**注意**  
要共享自动数据库集群快照，请通过复制自动快照来创建手动数据库集群快照，然后共享该副本。此过程也适用于 Amazon Backup 生成的资源。

有关复制快照的更多信息，请参阅[数据库集群快照复制](aurora-copy-snapshot.md)。有关从数据库集群快照还原数据库实例的更多信息，请参阅[从数据库集群快照还原](aurora-restore-snapshot.md)。

有关从数据库群集快照还原数据库群集的更多信息，请参阅 [备份和还原 Aurora 数据库集群的概述](Aurora.Managing.Backups.md)。

您可以与最多 20 个其他 Amazon Web Services 账户共享手动快照。

与其它 Amazon Web Services 账户共享手动快照时存在以下限制：
+ 当使用 Amazon Command Line Interface (Amazon CLI) 或 Amazon RDS API 从共享的快照还原数据库集群时，您必须指定共享快照的 Amazon 资源名称（ARN）作为快照标识符。

在以下各节中学习共享快照、公有快照和加密快照。还可以学习如何停止共享快照。

**Topics**
+ [共享快照](#aurora-share-snapshot.Sharing)
+ [共享公有快照](aurora-share-snapshot.public.md)
+ [共享加密的快照](share-encrypted-snapshot.md)
+ [停止快照共享](share-snapshot-stop.md)

## 共享快照
<a name="aurora-share-snapshot.Sharing"></a>

您可以使用 Amazon Web Services 管理控制台、Amazon CLI 或 RDS API 共享数据库集群快照。

### 控制台
<a name="aurora-share-snapshot.Console"></a>

使用 Amazon RDS 控制台，可以与多达 20 个 Amazon Web Services 账户共享手动数据库集群快照。您还可以使用该控制台停止与一个或多个账户共享手动快照。

**使用 Amazon RDS 控制台共享手动数据库集群快照**

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

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

1. 选择要共享的手动快照。

1. 对于 **Actions**（操作），请选择 **Share snapshot**（共享快照）。

1. 为 **DB snapshot visibility (数据库快照可见性)** 选择以下一个选项。
   + 如果源未加密，则选择**公有**以允许所有 Amazon Web Services 账户从您的手动数据库集群快照还原数据库集群，或选择**私有**以仅允许您指定的 Amazon Web Services 账户从手动数据库集群快照还原数据库集群。
**警告**  
如果将**数据库快照可见性**设置为**公有**，则所有 Amazon Web Services 账户均可从您的手动数据库集群快照还原数据库集群，并且可访问您的数据。请勿将包含私密信息的任何手动数据库集群快照以**公开**形式共享。  
有关更多信息，请参阅 [共享公有快照](aurora-share-snapshot.public.md)。
   + 如果源已加密，由于已加密的快照无法公开共享，**DB snapshot visibility (数据库快照可见性)** 将设为 **Private (私密)**。
**注意**  
无法共享已使用默认 Amazon KMS key 加密的快照。有关如何解决此问题的信息，请参阅[共享加密的快照](share-encrypted-snapshot.md)。

1. 对于 **Amazon 账户 ID**，输入您想要允许从您的手动快照还原数据库集群的账户的 Amazon Web Services 账户标识符，然后选择**添加**。重复操作以加入其它 Amazon Web Services 账户标识符，最多可包含 20 个 Amazon Web Services 账户。

   如果您在许可账户列表中错加了某个 Amazon Web Services 账户标识符，可以选择错误 Amazon Web Services 账户标识符右侧的**删除**将其从列表中删除。  
![\[允许 Amazon Web Services 账户还原手动数据库集群快照\]](http://docs.amazonaws.cn/AmazonRDS/latest/AuroraUserGuide/images/ShareSnapshot_add.png)

1. 为您想要允许还原手动快照的所有 Amazon Web Services 账户添加标识符以后，选择**保存**以保存您的更改。

### Amazon CLI
<a name="aurora-share-snapshot.CLI"></a>

要共享数据库集群快照，请使用 `aws rds modify-db-cluster-snapshot-attribute` 命令。使用 `--values-to-add` 参数添加有权还原手动快照的 Amazon Web Services 账户的 ID 列表。

**Example 与单个账户共享快照**  
以下示例使 Amazon Web Services 账户标识符 `123456789012` 能够还原名为 `cluster-3-snapshot` 的数据库集群快照。  
对于 Linux、macOS 或 Unix：  

```
aws rds modify-db-cluster-snapshot-attribute \
--db-cluster-snapshot-identifier cluster-3-snapshot \
--attribute-name restore \
--values-to-add 123456789012
```
对于：Windows  

```
aws rds modify-db-cluster-snapshot-attribute ^
--db-cluster-snapshot-identifier cluster-3-snapshot ^
--attribute-name restore ^
--values-to-add 123456789012
```

**Example 与多个账户共享快照**  
以下示例使两个 Amazon Web Services 账户标识符（`111122223333` 和 `444455556666`）能够还原名为 `manual-cluster-snapshot1` 的数据库集群快照。  
对于 Linux、macOS 或 Unix：  

```
aws rds modify-db-cluster-snapshot-attribute \
--db-cluster-snapshot-identifier manual-cluster-snapshot1 \
--attribute-name restore \
--values-to-add {"111122223333","444455556666"}
```
对于：Windows  

```
aws rds modify-db-cluster-snapshot-attribute ^
--db-cluster-snapshot-identifier manual-cluster-snapshot1 ^
--attribute-name restore ^
--values-to-add "[\"111122223333\",\"444455556666\"]"
```
使用 Windows 命令提示符时，必须在 JSON 代码中转义双引号 (")，方法是使用反斜杠 (\$1) 作为其前缀。

要列出能够用于还原快照的 Amazon Web Services 账户，请使用 [https://docs.amazonaws.cn/cli/latest/reference/rds/describe-db-cluster-snapshot-attributes.html](https://docs.amazonaws.cn/cli/latest/reference/rds/describe-db-cluster-snapshot-attributes.html) Amazon CLI 命令。

### RDS API
<a name="aurora-share-snapshot.API"></a>

您还可以使用 Amazon RDS API 与其它 Amazon Web Services 账户共享手动数据库集群快照。为此，请调用 [https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_ModifyDBClusterSnapshotAttribute.html](https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_ModifyDBClusterSnapshotAttribute.html) 操作。为 `AttributeName` 指定 `restore`，并使用 `ValuesToAdd` 参数添加有权还原手动快照的 Amazon Web Services 账户的 ID 列表。

要将手动快照设为公有并允许所有 Amazon Web Services 账户进行还原，请使用值 `all`。但请注意，若任何手动快照包含您不想向所有 Amazon Web Services 账户公开的私有信息，则不要添加 `all` 值。此外，由于此类快照不支持公开共享，请不要为已加密的快照指定 `all`。

要列出有权还原快照的所有 Amazon Web Services 账户，请使用 [https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_DescribeDBClusterSnapshotAttributes.html](https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_DescribeDBClusterSnapshotAttributes.html) API 操作。