Restore AWS RDS from xtrabackup through CloudFormation - amazon-web-services

maybe someone could help me.
I have Aurora cluster CloudFormation template ang I'm trying to restore database data from xtrabackup.
I can use this backup through GUI - AWS provide button "Restore Aurora DB cluster from S3". I think, I can do it through CLI, but I need restore this backup from CloudFormation. I found option DBSnapshotIdentifier, but, as I understand, this option works just with RDS Snapshots.
Do we have a way to do it?
Or, maybe I can restore this backup to exist RDS Cluster.

You need to take the backup you used and turn it into an AWS snapshot, so then you can reference it. While AWS Console does this for you it seems that CloudFormation doesn't offer that facility.

Related

How do I create a EBS snapshot without downtime to the instance?

Is it possible to create a snapshot of an EBS Volume without downtime via Terraform?
I am currently looking at documentation about resource aws_dlm_lifecycle_policy.
(https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dlm_lifecycle_policy)
Seems like it is possible. DLM lifecycle policy just automates snapshot creation.
Snapshots are created asynchronously, even from an attached volume which is in use. Consult with official AWS documentation here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html

How can I restore a snapshot to an existing Aurora db instance?

I redeployed an Auraro cluster (postgresql 11). I did it by delete the existing one and re-create a new one. I have snapshot backup from the previous db instance and I'd like to restore the data to the existing instance.
I understand that Aurora doesn't support it. Is there a workaround for me to do that? Like whether I can download the snapshot to local in plain sql script format. Then manually restore them to the new instance?
I understand that Aurora doesn't support it. Is there a workaround for
me to do that? Like whether I can download the snapshot to local in
plain sql script format. Then manually restore them to the new
instance?
You can certainly accomplish that by doing the following:
Restore the snapshot to a new cluster (Cluster B).
Export the data from that cluster using pgdump or mysqldump depending on the Aurora database engine you are using. I suggest doing this in an EC2 instance in the same VPC.
Delete Cluster B.
Drop the database in your original cluster (Cluster A).
Load all the data from the export into Cluster A.
However, at that point all you have accomplished is that you will have maintained the RDS cluster's endpoint URL. If you design your system to allow changes to the RDS endpoint URL, then it would be much easier for you to simply restore the snapshot to the new cluster, swap the endpoint your application connects to, and delete the old cluster.
You can use the method suggested by Teddy Aryono to restore the DB cluster.
Now rest is using DB host name, use secret manager to store your credentials so even if db host name is changing after restoring snapshot to new cluster you dont need to update application/lambda configurations.
(of-course you nee to update secret manager details with new host name after restore )
You can restore from a DB cluster snapshot that you have saved. To restore a DB cluster from a DB cluster snapshot, use the AWS CLI command restore-db-cluster-from-snapshot.
In this example, you restore from a previously created DB cluster snapshot named mydbclustersnapshot. You restore to a new DB cluster named mynewdbcluster. You use Aurora PostgreSQL.
Example:
For Linux, macOS, or Unix:
aws rds restore-db-cluster-from-snapshot \
--db-cluster-identifier mynewdbcluster \
--snapshot-identifier mydbclustersnapshot \
--engine aurora-postgresql
For Windows:
aws rds restore-db-cluster-from-snapshot ^
--db-cluster-identifier mynewdbcluster ^
--snapshot-identifier mydbclustersnapshot ^
--engine aurora-postgresql
Furthermore, you can also do it using AWS Management Console, or RDS API. Read this docs for details.

How to make AWS aurora Mysql into a writable instance

I am working on a project where we are creating a new region for resilience purpose.
As we create a new Region for the project, we also plan to create a Read replica of Aurora MySQL DB.
My question here has two parts
If the project in existing region goes down, how to make the read replica of Aurora MySQL in the other region as the new Master and writable?
I searched through few videos and stackoverflow questions and I do understand how to make the RDS mysql as writable instance. but, I don't see how to make such a "read-only" parameter modification in Aurora MySQL!
How could I do this change with a Jenkins Job?
Any help is highly appreciated!
Thanks!
You can use the AWS CLI for this, specifically the:
aws rds promote-read-replica-db-cluster
command which contrary to the name actually applies to Aurora as stated in the documentation for the command:
Note:
This action only applies to Aurora DB clusters.
You can find more information in the AWS documentation for Aurora, specifically the section on Promoting a Read Replica to Be a DB Cluster.
Seems like you should be able to use the Jenkins AWS plugin but there are many options.

How to copy redshift cluster snapshot from one account to another account through script

How to copy a redshift cluster snapshot from one account to another account through script.
To manually migrate an Amazon Redshift cluster to another AWS account, follow these steps:
Create a manual snapshot of the cluster you want to migrate.
Share the cluster snapshot with another AWS account to view and
restore the snapshot.
Before you copy a snapshot to another region, first enable
cross-region snapshots.
In the destination AWS account, restore the shared cluster snapshot.
Please see
https://aws.amazon.com/premiumsupport/knowledge-center/account-transfer-redshift/
If you want to do that in a "script" for some reason - then you need to read https://docs.aws.amazon.com/redshift/latest/mgmt/manage-snapshots-api-cli.html
I believe everything you need can be done using aws cli.

Documentation on AWS RDS "migrate snapshot"

I can't seem to find much information about the "migrate snapshot" option in the AWS/RDS documentation.
Is it correct to assume that it creates a new, totally separate database based on that snapshot and leaves the original database intact?
The Migrate Snapshot function spins up a new Aurora DB Cluster from a MySQL DB snapshot.
The Migrate Snapshot button in AWS Web Console is currently active only for MySQL snapshots. Naming and appearance of the button is unfortunate. It would probably be more intuitive to only show that button for when a MySQL snapshot is selected and name it as Restore to Aurora or Launch Aurora Cluster.
You can find more information about that function in the AWS RDS user guide under Migrating an RDS MySQL Snapshot to Aurora subsection of the Aurora on Amazon RDS section.
Yes, if you spin up an instance from an RDS snapshot, it creates a completely new instance and leaves the original intact.