I want to copy and restore an Amazon Redshift Serverless snapshot from one AWS account to another AWS account. How can I do that?
Resolution
Perform a copy and restore from one AWS account to another using the Amazon Redshift console or AWS Command Line Interface (AWS CLI).
Before you begin, consider the following:
- You can restore a snapshot to an Amazon Redshift Serverless namespace only if it's in Available status and is associated with an available workgroup.
- Restoring an Amazon Redshift Serverless namespace from a snapshot replaces all of the namespace's databases with databases in the snapshot.
- During the Restore, Amazon Redshift Serverless will be unavailable.
Copy and restore using the Amazon Redshift console
Convert a recovery point of Amazon Redshift Serverless to a snapshot in the source account
- Open the Amazon Redshift console.
- In the navigation pane, choose Redshift serverless, and then choose Data backup.
- Under Recovery points, choose the Creation time of the recovery point that you want to convert to a snapshot.
- Choose Create snapshot from recovery point.
- Enter a Snapshot identifier and retention period.
- Choose Create.
Share the snapshot in the source account with another AWS account
- Open the Amazon Redshift console.
- In the navigation pane, choose Redshift serverless, and then choose Data backup.
- Choose the snapshot you created previously.
- Choose Actions, Manage access.
- Choose Add AWS account located under Provide access to serverless accounts and enter an AWS account ID (destination).
- Choose Save changes.
Restore the snapshot to an Amazon Redshift Serverless namespace in the destination account
- Open the Amazon Redshift console.
- In the navigation pane, choose Redshift serverless, and then choose Data backup.
- Choose the snapshot shared to the AWS account ID to restore. You can restore only one snapshot at a time.
- Choose Actions, Restore to serverless namespace.
- Choose an available namespace to restore to. You can restore to only namespaces with an Available status.
- Choose Restore.
Copy and restore using the AWS CLI
Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
Convert a recovery point of Amazon Redshift Serverless to a snapshot in the source account
1. Use the list-recovery-points command for a list of snapshots created after a start-time. Run the following command, and replace namespacename with your namespace, us-west-2 with your AWS Region, and starttime with your recovery point start time in UTC:
aws redshift-serverless list-recovery-points --namespace-name <namespacename> --region <region name> --start-time <starttime>
In the following example, the Redshift Serverless cluster is in the US West (Oregon) Region with a namespace of default and a start time of 2022-09-06T07:10 UTC:
aws redshift-serverless list-recovery-points --namespace-name default --region us-west-2 --start-time 2022-09-06T07:10
2. Use the convert-recovery-point-to-snapshot command to create a snapshot and retention period. Run the following command, and replace recoveryPointId with the recovery point ID output from step 1, days with the number of days to retain the snapshot, snapshot name with your snapshot's name, and us-west-2 with your AWS Region:
aws redshift-serverless convert-recovery-point-to-snapshot --recovery-point-id <recoveryPointId> --retention-period <days> --snapshot-name <snapshot name> --region <region name>
In the following example, the snapshot is named snapshot01 with a retention period of three days, and is in the US West (Oregon) Region**.**
aws redshift-serverless convert-recovery-point-to-snapshot --recovery-point-id 72acee50-34df-45f6-865f-46aa178ada82 --retention-period 3 --snapshot-name snapshot01 --region us-west-2
3. Use the get-snapshot command to confirm the snapshot was created. Run the following command, and replace snapshot name with the name of your snapshot:
aws redshift-serverless get-snapshot --snapshot-name <snapshot name>
Share the snapshot in the source account with another AWS account
Use the put-resource-policy command to provide another AWS account access to the snapshot. Run the following command, and replace destination account ID with the destination AWS account ID and snapshot arn with the snapshot's ARN:
aws redshift-serverless put-resource-policy --policy "{\"Version\": \"2012-10-17\", \"Statement\" : [{ \"Sid\": \"AllowUserRestoreFromSnapshot\", \"Principal\":{\"AWS\": [\”<destination account ID>\”]}, \"Action\": [\"redshift-serverless:RestoreFromSnapshot\"] , \"Effect\": \"Allow\" }]}" --resource-arn <snapshot arn>
In the following example, access is provided to the snapshot ARN in account number 123456789012:
aws redshift-serverless put-resource-policy --policy "{\"Version\": \"2012-10-17\", \"Statement\" : [{ \"Sid\": \"AllowUserRestoreFromSnapshot\", \"Principal\":{\"AWS\": [\"123456789012\"]}, \"Action\": [\"redshift-serverless:RestoreFromSnapshot\"] , \"Effect\": \"Allow\" }]}" --resource-arn arn:aws:redshift-serverless:us-west-2:112233445566:snapshot/4978ca91-24ba-4196-91ad-9d372f72b0fe
Restore the snapshot to an Amazon Redshift Serverless namespace in the destination account
1. Use the list-snapshots command to list the snapshot in your AWS Region. Run the following command, and replace us-west-2 with your AWS Region:
aws redshift-serverless list-snapshots --region us-west-2
2. Use the restore-from-snapshot command to restore the snapshot to an Amazon Redshift Serverless. Run the following command, and replace snapshot name with the name of your snapshot, workgroup name with the name of your workgroup, and snapshot arn with the snapshot ARN from the preceding command:
aws redshift-serverless restore-from-snapshot --namespace-name <namespace name > --workgroup-name <workgroup name> --snapshot-arn <snapshot arn>
In the following example, the account ID 112233445566 has an Amazon Redshift Serverless in Available state with a namespace name of restore and a workgroup name of restore:
aws redshift-serverless restore-from-snapshot --namespace-name restore --workgroup-name restore --snapshot-arn arn:aws:redshift-serverless:us-west-2:112233445566:snapshot/4978ca91-24ba-4196-91ad-9d372f72b0fe