Restoring to a Point in Time - Amazon DocumentDB

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).

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.

Using the AWS Management Console

You can restore a cluster to a point-in-time within its backup retention period using the console.

To restore a cluster to a point-in-time

  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 () 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.

    
                     Screenshot: Restore to point in time, Restore time section.
    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.

    
                     Screenshot: Restore to point in time, 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, Amazon Neptune, and Amazon DocumentDB) per AWS account, per Region.

    2. Instance class—In the list, choose the instance class that you want for the cluster's instances.

    3. Number of instances—In the 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 those sections. Otherwise continue with the next step.

    • Network settings

      
                           Screenshot of the Log exports pane showing the steps to configure the cluster's DML logging.
      1. Virtual Private Cloud (VPC)—In the list, choose the VPC that you want to use for this cluster.

         

      2. Subnet group—In the list, choose the subnet group for this cluster.

         

      3. VPC security groups—In the list, choose the VPC security groups for the 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

      
                           Screenshot of the Log exports pane showing the steps to configure the cluster's DML logging.
      1. Export auditing logs to Amazon CloudWatch—Choose one of the following:

        • Enabled—Enables your cluster to export DML logging to Amazon CloudWatch Logs.

        • Disabled—Prevents your cluster from exporting DML logs to Amazon CloudWatch Logs. Disabled is the default.

           

      2. IAM role—From the list, choose RDS Service Linked Role.

  7. Complete the process.

    • To restore the cluster, choose Create cluster.

    • To cancel the operation, choose Cancel.

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.

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, Amazon Neptune, and Amazon DocumentDB) per AWS account, per Region.

  • --restore-to-time—The UTC date and time to restore the cluster to.

    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-20181102182833-snapshot to the latest restorable time.

For Linux, macOS, or Unix:

aws docdb restore-db-cluster-to-point-in-time \ --db-cluster-identifier sample-cluster-restored \ --source-db-cluster-identifier sample-cluster-20181102182833-snapshot \ --use-latest-restorable-time

For Windows:

aws docdb restore-db-cluster-to-point-in-time ^ --db-cluster-identifier sample-cluster-restored ^ --source-db-cluster-identifier sample-cluster-20181102182833-snapshot ^ --use-latest-restorable-time

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

For Linux, macOS, or Unix:

aws docdb restore-db-cluster-to-point-in-time \ --db-cluster-identifier sample-cluster-restored \ --source-db-cluster-identifier sample-cluster-2018-12-02-00-07 \ --restore-type full-copy \ --restore-to-time 2018-12-11T03:15:00Z

For Windows:

aws docdb restore-db-cluster-to-point-in-time ^ --db-cluster-identifier sample-cluster-restored ^ --source-db-cluster-identifier sample-cluster-2018-12-02-00-07 ^ --restore-type full-copy ^ --restore-to-time 2018-12-11T03:15:00Z

Output from this operation looks something like the following (JSON format).

{ "DBCluster": { "PreferredMaintenanceWindow": "wed:06:28-wed:06:58", "DBClusterArn": "arn:aws:rds:us-east-1:123456789012:cluster:sample-cluster-restored", "ClusterCreateTime": "2018-12-11T18:21:32.473Z", "DBSubnetGroup": "default", "ReaderEndpoint": "sample-cluster-restored.cluster-ro-dvuterjxdl57.us-east-1.docdb.amazonaws.com", "Status": "creating", "MasterUsername": "<user-name>", "IAMDatabaseAuthenticationEnabled": false, "Engine": "docdb", "HostedZoneId": "Z2SUY0A1719RZT", "EngineVersion": "3.6.0", "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "ReadReplicaIdentifiers": [], "AssociatedRoles": [], "StorageEncrypted": false, "AllocatedStorage": 1, "BackupRetentionPeriod": 1, "DbClusterResourceId": "cluster-GTAQPS34Y5WU7UYSH3EH2YCQRG", "DBClusterMembers": [], "MultiAZ": false, "AvailabilityZones": [ "us-east-1b", "us-east-1c", "us-east-1a" ], "DBClusterIdentifier": "sample-cluster-restored", "DBClusterParameterGroup": "default.docdb3.6", "Endpoint": "sample-cluster-restored.cluster-dvuterjxdl57.us-east-1.docdb.amazonaws.com", "PreferredBackupWindow": "00:00-00:30", "Port": 27017 } }