Restoring to a Point in Time

You can restore a cluster to any point in time that is within the cluster’s backup retention period using the AWS Management Console or AWS Command Line Interface (AWS CLI).

Note

You cannot conduct a point-in-time restore of a 3.6 cluster to a 4.0 cluster but you can migrate from one cluster version to another. For more information, go to Migrating to Amazon DocumentDB.

Keep the following in mind when restoring a cluster to a point in time.

  • The new cluster is created with the same configuration as the source cluster, except that the new cluster is created with the default parameter group. To set the new cluster’s parameter group to the source cluster’s parameter group, modify the cluster after it is available. For more information on modifying a cluster, see Modifying an Amazon DocumentDB Cluster.

Restore to a Point in Time Using the AWS Management Console

You can restore a cluster to a point-in-time within its backup retention period by completing the following using the AWS Management Console.

  1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/docdb.

  2. In the navigation pane, choose Clusters. In the list of clusters, choose the button to the left of the cluster that you want to restore.

    Tip

    If you don’t see the navigation pane on the left side of your screen, choose the menu icon (Restoring to a Point in Time - 图1) in the upper-left corner of the page.

  3. On the Actions menu, choose Restore to point in time.

  4. Complete the Restore time section, which specifies the date and time to restore to.

    1. Restore date—Choose or enter a date that is between the Earliest restore time and the Latest restore time.

    2. Restore time—Choose or enter the hour, minute, and seconds that are between the Earliest restore time and the Latest restore time.

  5. Complete the Configuration section.

    1. Cluster identifier — Accept the default identifier, or enter an identifier that you prefer.

      Cluster naming constraints:

      • Length is [1—63] letters, numbers, or hyphens.

      • First character must be a letter.

      • Cannot end with a hyphen or contain two consecutive hyphens.

      • Must be unique for all clusters across Amazon RDS, Neptune and Amazon DocumentDB per AWS account, per Region.

    2. Instance class — From the drop-down list, choose the instance class that you want for the cluster’s instances.

    3. Number of instances — From the drop-down list, choose the number of instances that you want created when the cluster is restored.

  6. Optional. To configure the network settings, cluster options, and enable log exports, choose Show advanced settings, and then complete the following sections. Otherwise, continue with the next step.

    • Network settings

      1. Virtual Private Cloud (VPC) — From the drop-down list, choose the VPC that you want to use for this cluster.

      2. Subnet group — From the drop-down list, choose the subnet group for this cluster.

      3. VPC security groups — From the drop-down list, choose the VPC security groups for this cluster.

    • Cluster options

      1. Port — Accept the default port (27017), or use the up and down arrows to set the port for communicating with this cluster.
    • Log exports

      1. Audit logs — Select this option to enable exporting audit logs to Amazon CloudWatch Logs. If you select this option, you must enable audit_logs in the cluster’s custom parameter group. For more information, see Auditing Amazon DocumentDB Events.

      2. Profiler logs — Select this option to enable exporting operation profiler logs to Amazon CloudWatch Logs. If you select this option, you must also modify the following parameters in the cluster’s custom parameter group:

        • profiler — Set to enabled.

        • profiler_threshold_ms — Set to a value [0-INT_MAX] to set the threshold for profiling operations.

        • profiler_sampling_rate — Set to a value [0.0-1.0] to set the percentage of slow operations to profile.

        For more information, see Profiling Amazon DocumentDB Operations.

      3. Profiler logs — Export profiler logs to Amazon CloudWatch

      4. IAM role — From the drop-down list, choose RDS Service Linked Role.

    • Tags

      1. Add Tag — In the Key box, enter the name for the tag for your cluster. In the Value box, optionally enter the tag value. Tags are used with AWS Identity and Access Management (IAM) policies to manage access to Amazon DocumentDB resources and to control what actions can be applied to the resources.
    • Deletion protection

      1. Enable deletion protection — Protects the cluster from being accidentally deleted. While this option is enabled, you can’t delete the cluster.
  1. To restore the cluster, choose Create cluster. Alternatively, you can choose Cancel to cancel the operation.

Restore To a Point in Time Using the AWS CLI

To restore a cluster to a point in time using the snapshot’s backup retention period, use the restore-db-cluster-to-point-in-time operation with the following parameters.

  • --db-cluster-identifier — Required. The name of the new cluster to be created. This cluster cannot exist before the operation. The parameter value must meet the following constraints.

    Cluster naming constraints:

    • Length is [1—63] letters, numbers, or hyphens.

    • First character must be a letter.

    • Cannot end with a hyphen or contain two consecutive hyphens.

    • Must be unique for all clusters across Amazon RDS, Neptune and Amazon DocumentDB per AWS account, per Region.

  • --restore-to-time — The UTC date and time to restore the cluster to. For example, 2018-06-07T23:45:00Z.

    Time Constraints:

    • Must be before the latest restorable time for the cluster.

    • Must be specified if the --use-latest-restorable-time parameter is not provided.

    • Cannot be specified if the --use-latest-restorable-time parameter is true.

    • Cannot be specified if the --restore-type parameter value is copy-on-write.

  • --source-db-cluster-identifier — The name of the source cluster from which to restore. This cluster must exist and be available.

  • --use-latest-restorable-time or --no-use-latest-restorable-time — Whether to restore to the latest restorable backup time. Cannot be specified if the --restore-to-time parameter is provided.

The AWS CLI operation restore-db-cluster-to-point-in-time only restores the cluster, not the instances for that cluster. You must invoke the create-db-instance operation to create instances for the restored cluster, specifying the identifier of the restored cluster in --db-cluster-identifier. You can create instances only after the restore-db-cluster-to-point-in-time operation has completed and the restored cluster is available.

The following example creates sample-cluster-restored from the snapshot sample-cluster-snapshot to the latest restorable time.

For Linux, macOS, or Unix:

  1. aws docdb restore-db-cluster-to-point-in-time \
  2. --db-cluster-identifier sample-cluster-restored \
  3. --source-db-cluster-identifier sample-cluster-snapshot \
  4. --use-latest-restorable-time

For Windows:

  1. aws docdb restore-db-cluster-to-point-in-time ^
  2. --db-cluster-identifier sample-cluster-restored ^
  3. --source-db-cluster-identifier sample-cluster-snapshot ^
  4. --use-latest-restorable-time

The following example creates sample-cluster-restored from the snapshot sample-cluster-snapshot to 03:15 on December 11, 2018 (UTC), which is within the backup retention period of sample-cluster.

For Linux, macOS, or Unix:

  1. aws docdb restore-db-cluster-to-point-in-time \
  2. --db-cluster-identifier sample-cluster-restore \
  3. --source-db-cluster-identifier sample-cluster \
  4. --restore-to-time 2020-05-12T03:15:00Z

For Windows:

  1. aws docdb restore-db-cluster-to-point-in-time ^
  2. --db-cluster-identifier sample-cluster-restore ^
  3. --source-db-cluster-identifier sample-cluster ^
  4. --restore-to-time 2020-05-12T03:15:00Z

Output from this operation looks something like the following.

  1. {
  2. "DBCluster": {
  3. "AvailabilityZones": [
  4. "us-east-1c",
  5. "us-west-2b",
  6. "us-west-2a"
  7. ],
  8. "BackupRetentionPeriod": 1,
  9. "DBClusterIdentifier": "sample-cluster-restored",
  10. "DBClusterParameterGroup": "sample-parameter-group",
  11. "DBSubnetGroup": "default",
  12. "Status": "creating",
  13. "Endpoint": "sample-cluster-restored.node.us-east-1.docdb.amazonaws.com",
  14. "ReaderEndpoint": "sample-cluster-restored.node.us-east-1.docdb.amazonaws.com",
  15. "MultiAZ": false,
  16. "Engine": "docdb",
  17. "EngineVersion": "4.0.0",
  18. "Port": 27017,
  19. "MasterUsername": "master-user",
  20. "PreferredBackupWindow": "02:00-02:30",
  21. "PreferredMaintenanceWindow": "tue:09:50-tue:10:20",
  22. "DBClusterMembers": [],
  23. "VpcSecurityGroups": [
  24. {
  25. "VpcSecurityGroupId": "sg-abc0123",
  26. "Status": "active"
  27. }
  28. ],
  29. "HostedZoneId": "ABCDEFGHIJKLM",
  30. "StorageEncrypted": true,
  31. "KmsKeyId": "arn:aws:kms:us-east-1:<accountID^>:key/sample-key",
  32. "DbClusterResourceId": "cluster-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  33. "DBClusterArn": "arn:aws:rds:us-east-1:<accountID>:cluster:sample-cluster-restored",
  34. "AssociatedRoles": [],
  35. "ClusterCreateTime": "2020-04-24T20:14:36.713Z",
  36. "DeletionProtection": false
  37. }
  38. }