View a markdown version of this page

Backing up and restoring a database cluster group for Aurora - Amazon Aurora

Backing up and restoring a database cluster group for Aurora

In a database cluster group for Aurora, you can back up every member cluster together and restore related member clusters to a consistent point in time. A group snapshot and a point-in-time restore of the group both return every member cluster to the same point in time. Group backups work with routing enabled or disabled. Each member cluster also keeps its own Aurora backups, as described in Backing up and restoring an Amazon Aurora DB cluster. You can bring data back in the following ways:

  • Restore the whole group from a group snapshot or to a point in time, as a new group.

  • Restore one member cluster on its own, from its own backups, as a new standalone cluster.

  • Restore the data mappings from your mapping export, as described in Exporting the mappings before and after a change. A member cluster snapshot holds no mappings.

How group backups and restores work

When you restore a group to a point in time or from a group snapshot, each member cluster holds every transaction whose commit it acknowledged before that time, and no transaction that began after it. A transaction is never partly restored: the restored group holds all of its rows or none of them. The restore also keeps the order of commits across member clusters. If your application commits on one member cluster, receives the acknowledgment, and then commits on another, a restored group that holds the second change also holds the first. Restoring member clusters one at a time to the same time doesn't give this guarantee.

The group has a restorable window, bounded by a latest and an earliest restorable time, and both come from its member clusters:

  • The group's latest restorable time is the earliest of the member clusters' latest restorable times, so the member cluster that's furthest behind sets it.

  • The earliest restorable time sets how far back within the group's retention period you can restore the group. It tracks the current time, so if the latest restorable time stops advancing, the window narrows, closing once the latest restorable time falls a full retention period behind.

  • While a member cluster has no DB instances, or while its writer instance is stopped, has incompatible parameters, or has an inaccessible KMS key, the group's latest restorable time doesn't wait for that cluster. It keeps advancing with the other member clusters. If you restore the group to a time after the problem started, the other member clusters are restored to that time, but that cluster is restored only to its own latest restorable time: the point when it lost its DB instances or its writer instance became unavailable. If this applies to every member cluster, the group's latest restorable time stops advancing.

A restore creates a new group. A point-in-time restore reproduces the group's membership as it stood at the restore time: a member cluster added after that time isn't in the restored group, and a member cluster removed after that time is in it.

Group backups and member cluster backups exist side by side. Each member cluster keeps its own cluster-level backups, unchanged by group membership. You set the group's retention period and each member cluster's retention period separately, as described in Automated backups and retention. Deleting a member cluster's automated backup, or letting it expire, doesn't remove data that the group backup still needs.

The service creates the group's backup resource with the group, and deletes it only when you delete the group. Calls against it need their own IAM permissions, which they don't inherit from the group. For the actions, see IAM and API permissions.

Automated backups and retention

The group's automated backups are always on. You set the retention period, with a minimum of 1 day, and the backup window on the group, with CreateDBClusterGroup or ModifyDBClusterGroup. These settings are separate from each member cluster's own retention period and backup window. The group backup window must not overlap the maintenance window of the group or of any member cluster. For the settings, see Changing group settings.

The group's retention period can never be longer than any member cluster's retention period. A request that would leave a member cluster's retention period shorter than the group's fails.

To give the group a longer retention period, raise it on every member cluster first. To give a member cluster a shorter one, lower the group's first.

Each member cluster produces two automated snapshots each day: one that the group coordinates in the group's backup window, and one that the member cluster takes in its own window. An automated snapshot that the group takes expires at the end of the group's retention period, and an automated snapshot that the member cluster takes expires at the end of the member cluster's retention period.

Retained automated backups

When you delete a group and keep its automated backup, the service retains that backup for up to the group's retention period. The service takes no new snapshots or logs during that time, so the restore window shrinks. To list it, call DescribeDBClusterGroupAutomatedBackups with the group's resource ID. To restore it, call RestoreDBClusterGroupToPointInTime with the group's resource ID as the source. To delete it, call DeleteDBClusterGroupAutomatedBackup with the group's resource ID.

In the console, the retained automated backups of a deleted group appear under Retained cluster group backups. There, you can restore a new group from a retained backup or delete the backup.

Creating a snapshot of a database cluster group for Aurora

A manual snapshot of a database cluster group for Aurora, or manual group snapshot, is one resource that captures every member cluster at the group's latest restorable time. It records the engine version and the cluster identifier of every member cluster when it was taken, and removing a member cluster later doesn't change it. The member cluster snapshots inside it don't appear in DescribeDBClusterSnapshots, and you can't delete, restore, or tag them on their own. Create a group snapshot before a change that you might need to undo, such as an upgrade.

To create a group snapshot
  1. Read the group's LatestRestorableTime from DescribeDBClusterGroups. The group snapshot captures every member cluster at that time, so check that it includes the changes that you want to keep.

  2. With the console, the AWS CLI, or the Amazon RDS API, create the group snapshot.

  3. Call DescribeDBClusterGroupSnapshots and read the snapshot's Status and SnapshotDatabaseTime. SnapshotDatabaseTime is the point in time that the snapshot captured, which is the group's latest restorable time when the snapshot was taken. SnapshotCreateTime is when you created the snapshot, and is later.

    aws rds describe-db-cluster-group-snapshots --region REGION --db-cluster-group-identifier GROUP_IDENTIFIER
Console
To create a group snapshot (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Database cluster groups, and then choose the group.

  3. Choose Actions, and then choose Take snapshot.

  4. For Snapshot identifier, enter a name for the snapshot.

  5. Confirm the snapshot.

The snapshot appears under Snapshots on the group's Maintenance & backups tab.

AWS CLI
aws rds create-db-cluster-group-snapshot --region REGION \ --db-cluster-group-identifier GROUP_IDENTIFIER --db-cluster-group-snapshot-identifier SNAPSHOT_IDENTIFIER
Amazon RDS API

Call CreateDBClusterGroupSnapshot with DBClusterGroupIdentifier and DBClusterGroupSnapshotIdentifier.

DescribeDBClusterGroupSnapshots reports each snapshot's member clusters as they were when it was taken. You can filter by group identifier, snapshot identifier, snapshot type, or engine. The operation returns up to 100 records for each page, with a marker for the next page. To list only one kind of snapshot, set the snapshot type to manual or automated. To delete a group snapshot that you no longer need, call DeleteDBClusterGroupSnapshot with the snapshot identifier.

CopyTagsToSnapshot is a group setting that copies the group's tags to the group snapshots that Aurora takes from it, as described in Tagging a database cluster group for Aurora. Tags aren't copied by default. If you specify tags when you create a group snapshot, Aurora doesn't copy the group's tags to that snapshot, even when CopyTagsToSnapshot is on.

Finding a restore point

You can restore a group to any second between the group's EarliestRestorableTime and LatestRestorableTime from DescribeDBClusterGroups. Read both values before you plan a restore, because the earliest restorable time moves forward continuously. In the console, the Maintenance & backups tab of the group shows them as Earliest restorable time and Latest restorable time.

To read the group's automated backup and its restore window, call DescribeDBClusterGroupAutomatedBackups.

aws rds describe-db-cluster-group-automated-backups --region REGION --db-cluster-group-identifier GROUP_IDENTIFIER

To read the member clusters that the group had at a given time, call DescribeDBClusterGroupAutomatedBackupMembers. It needs both the group identifier and the restore time.

aws rds describe-db-cluster-group-automated-backup-members --region REGION \ --db-cluster-group-identifier GROUP_IDENTIFIER --restore-to-time RESTORE_TIME

The command returns each member cluster with its resource ID. A restore to that time recreates these member clusters. When you restore the group, you pass each resource ID as the SourceDBClusterResourceId of an entry in MemberClusterOverrides, as described in Restoring a group.

Restoring a group

A group restore creates a new group in the same AWS account and AWS Region, with every member cluster restored into it. The source group is unchanged. The source can be a group snapshot, or a point in time within the group's automated backup. Name the source group by its identifier or by its resource ID. After you delete a group, it is identified by its resource ID, and the restore reads its retained automated backup, as described in Retained automated backups. We recommend that you rehearse on a test group, and keep the source group serving until the restored group passes the checks. For how a cluster restore works, see Restoring from a DB cluster snapshot and Restoring a DB cluster to a specified time.

To restore a group
  1. With the console, the AWS CLI, or the Amazon RDS API, restore the group to a point in time or from a group snapshot. The restore creates new member clusters, with their own storage. Optionally, turn routing on with EnableRouting, and set the restored member clusters' identifiers and settings with MemberClusterProvisioningConfiguration and MemberClusterOverrides. For a setting that you leave out, the restore uses the source member cluster's value, as described after this procedure.

  2. Set each restored member cluster's parameter group and capacity range to the source member clusters' values with ModifyDBCluster.

  3. With the console, the AWS CLI, or the Amazon RDS API, add a writer DB instance to each restored member cluster after the restore finishes. Choose an instance class that member clusters support, as listed in General limitations. For more information, see Restoring from a DB cluster snapshot.

  4. At the new routing endpoint, read the member cluster aliases and the data mappings, and compare them with your export. Map each old alias to its restored alias. Recreate any routing configuration that the restored group doesn't have from your export.

    SELECT * FROM dbclustergroup_sys.member_cluster_mappings; SELECT * FROM dbclustergroup_sys.data_mappings;
  5. At the new routing endpoint, confirm that the application's router users and member cluster users sign in. Reapply the tags that you need with AddTagsToResource.

  6. In the application's configuration, point connections at the new routing endpoint, reads first. Keep the source group until you verify the restored group.

Settings in MemberClusterProvisioningConfiguration, such as the DB subnet group, apply to every restored member cluster. Settings that differ for one member cluster go in MemberClusterOverrides, which takes one entry for each member cluster that you name or configure. In each entry, SourceDBClusterResourceId identifies the source member cluster, and you set that cluster's new identifier, its own provisioning configuration, or both. For a restored member cluster that you don't name, Aurora derives an identifier from the source cluster's identifier and the new group's identifier.

Console
To restore a group to a point in time (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Database cluster groups, and then choose the group.

  3. Choose Actions, and then choose Restore to point in time.

  4. Under Restore point, choose the latest restorable time or a custom time.

  5. For New cluster group identifier, enter a name for the new group.

  6. Under Members to restore, review the member clusters, which are the members of the group at the time that you chose. For each cluster that the console highlights, choose a DB subnet group.

  7. Choose Restore.

To restore a group from a group snapshot (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Database cluster groups, and then choose the group.

  3. On the Maintenance & backups tab, under Snapshots, select the snapshot.

  4. Choose Restore snapshot.

  5. For New cluster group identifier, enter a name for the new group, and then choose its other settings.

  6. Choose Restore.

After the restore finishes, add a writer DB instance to each restored member cluster before you connect to the cluster. To add them, on the Member clusters tab of the new group, select the clusters, and then choose Add instances.

AWS CLI

To restore to the latest time, pass --use-latest-restorable-time instead of --restore-to-time.

aws rds restore-db-cluster-group-to-point-in-time --region REGION \ --source-db-cluster-group-identifier GROUP_IDENTIFIER --db-cluster-group-identifier NEW_GROUP_IDENTIFIER \ --restore-to-time RESTORE_TIME --enable-routing \ --member-cluster-provisioning-configuration '{"DBSubnetGroupName":"SUBNET_GROUP"}' \ --routing-endpoint-configuration '{"VpcSubnetIds":["SUBNET_1","SUBNET_2"]}' aws rds restore-db-cluster-group-from-snapshot --region REGION \ --db-cluster-group-snapshot-identifier SNAPSHOT_IDENTIFIER --db-cluster-group-identifier NEW_GROUP_IDENTIFIER \ --enable-routing \ --member-cluster-provisioning-configuration '{"DBSubnetGroupName":"SUBNET_GROUP"}' \ --routing-endpoint-configuration '{"VpcSubnetIds":["SUBNET_1","SUBNET_2"]}'

The restored group keeps the source's administrative router user. To change its password, use --admin-user-password.

Amazon RDS API

To restore a group to a point in time, call the Amazon RDS API RestoreDBClusterGroupToPointInTime operation with the following parameters:

  • DBClusterGroupIdentifier

  • SourceDBClusterGroupIdentifier or SourceDBClusterGroupResourceId

  • RestoreToTime or UseLatestRestorableTime

To restore a group from a group snapshot, call RestoreDBClusterGroupFromSnapshot with DBClusterGroupIdentifier and DBClusterGroupSnapshotIdentifier.

A group snapshot and a group automated backup both include the group's routing metadata: its data mappings, scaleout table definitions, and routing functions. The restored group holds the same routing metadata that the source group held. You can't restore the routing metadata on its own. To bring back mappings without a restore, apply your mapping export, as described in Exporting the mappings before and after a change.

A restore turns routing off unless you ask for it. To turn routing on in the restored group, set EnableRouting and RoutingEndpointConfiguration in the restore call, as in a create call. You can also turn it on later with ModifyDBClusterGroup. For the routing settings, see Creating a database cluster group for Aurora.

A restored group whose retention period is longer than a restored member cluster's enters the incompatible-restore state, and you can't add a member cluster to it. Delete that group, or restore again with a group retention period that every member cluster covers.

If a restore is refused, stops, or doesn't produce the member clusters that you expected, see An upgrade or restore problem.

Restoring a database cluster group for Aurora doesn't resume a data movement job. If a data movement job was in progress at the restore point, Aurora cancels that job in the restored group. It also removes the objects that the job created. The original job continues to run in the source group. To check the job's status in the restored group, query dbclustergroup_data_movement.move_info at the restored group's routing endpoint.

Restoring an individual member cluster

A group restore always returns the whole group, and you can't restore one member cluster from a group backup. To recover one member cluster on its own, restore it from that member cluster's own backups, as for any Aurora DB cluster. For more information, see Restoring a DB cluster to a specified time and Restoring from a DB cluster snapshot.

A restored copy of a member cluster is a new standalone cluster, and the original group stays unchanged. To keep every member cluster at the same point in time, restore the whole group instead. You can't backtrack a member cluster in place while it's in a group.

As with a group restore, restoring a member cluster on its own doesn't resume a data movement job. The restored DB cluster isn't a member of a database cluster group for Aurora. Therefore, Aurora removes the objects that it created for group membership, including any data movement job that was in progress at the restore point. Your data on the cluster isn't removed. The original job continues to run in the group that the source member cluster belongs to.