AWS RDS Automated Backup and Snapshots - how to make both? - amazon-web-services

I'm familiar with the differences between "Automated Backups" and Snapshots. I'm trying to backup using both of them, but from the Modify-section of DB I find only Backup and Backtrack, and to my understanding, the backups from the Backup-section ( https://i.imgur.com/LwdMy8T.png ) should be going under "Automated Backups", right? But they're going under Automated Snapshots.
How do I create Automated Backup instead of snapshot?
E. I'm Using Amazon Aurora, I suppose that makes it a little different than other RDS!

Automated backups are always enabled on Amazon Aurora DB Instances.

Firstly to understand the difference between a snapshot & an automated backup:
Amazon RDS creates and saves automated backups of your DB instance. Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases.
Both of which are automatically active when you create an RDS unless you specify otherwise while creating the RDS instance:
Secondly regarding your amazon aurora question, it does the same thing as a normal RDS creating automated backups & snapshots:
Automated backups are always enabled on Amazon Aurora DB Instances. Backups do not impact database performance.
References: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html
https://aws.amazon.com/rds/aurora/faqs/#Backup_and_Restore

Related

AWS RDS Aurora cluster enable encryption

I am having an AWS RDS Aurora PostgreSQL cluster with four instances with a Multi-AZ deployment serving in Production. Encryption-at-rest hasn't been enabled on this cluster. Now I have to enable the encryption on this existing cluster. AWS docs suggest me to create a snapshot of that cluster and then restore the cluster again with the encryption enabled this time. Ref: Here
Since my cluster is serving in production and no downtime or I/O suspension is acceptable to me. Here are some questions that I would like to get answered before I plan about encrypting the existing cluster:
Is there any downtime during the creation of the snapshot assuming there is a lot of data and a snapshot will take time.
What about the new data that is being written on to the database during the snapshot creation? Is the snapshot creation real-time or I will lose my new data during the time till the snapshot is being taken?
Is this the only way for me to enable encryption on the production cluster knowing that it will result in some database outage?
There is a way to encrypt your AWS RDS Amazon Aurora with PostgreSQL compatibility Cluster with no or minimum downtime, but it will take a bit of effort.
You need to take the following steps:
For the source DB, you have to take snapshot.
Then copy that snapshot, and check Enable Encryption and select Default Encryption Key or select your Custom AWS KMS CMK, now you have an encrypted copy of your DB snapshot.
Restore this encrypted snapshot to the new DB instance, and you can enable Multi-AZ and add Read Replicas now or modify them after migration.
Now you have two DB instances Encrypted and Unencrypted, but the data mismatched as it is a production database.
We will use AWS DMS to make synchronous replication of data, or ou can use PostgreSQL logical replication with Aurora instead of AWS DMS, it will be better, both will works.
Go to AWS DMS console, create an AWS DMS task.
For migration type, choose Migrate existing data and replicate ongoing changes.
For target table preparation mode, choose Truncate.
Under Advanced Task Settings, enable the awsdms_status table if you want to verify replication status.
Run the migration task and wait until all the records are updated. AWS DMS will then determine the size of the data to migrate.
Then, you need to verify the data in the Encrypted DB instance after migration is the same as the Unencrypted DB instance.
Check replication status in AWS DMS, by checking the migration task and awsdms_status.
You can now route traffic to the new endpoint.
For a smooth cutover, use Amazon Route 53 to route traffic by changing the DNS TTL to a short value, and eventually replacing the endpoint names in Route 53.
Now replying to your questions,
Is there any downtime during the creation of the snapshot assuming there is a lot of data and a snapshot will take time.
According to you cluster setup, you are running a Multi-AZ deployment, automated backups and DB Snapshots are simply taken from the standby to avoid I/O suspension on the primary. Please note that you may experience increased I/O latency (typically lasting a few minutes) during backups for both Single-AZ and Multi-AZ deployments.
What about the new data that is being written on to the database during the snapshot creation? Is the snapshot creation real-time or I
will lose my new data during the time till the snapshot is being
taken?
You will lose your data written after the snapshot has been taken, so you will use AWS DMS to replicate synchronous data to your encrypted DB instances.
Is this the only way for me to enable encryption on the production cluster knowing that it will result in some database outage?
Yes this is the only way, but it will result in no or little downtime.

AWS RDS - creating a "replica" database daily automatically

Apologies if this isn't the right place to ask this question.
I'm looking to create an automated copy (backup) of my AWS RDS (MySQL) database daily and have this backup restored daily to another RDS instance and made available to another set of applications
I already have daily backups running and I can create a new rds instance from a backup but I want this to happen automatically within AWS.
Looking through AWS documentation and I can't find anything that fits this purpose but maybe there's a service that I'm not aware of.
AWS Aurora for MySQL and PostgreSQL support AutoScaling.
Autoscaling dynamically adjusts the number of Replicas available for cluster based on different metrics and policy. When sudden workload increase it'll add move read replicas and when it'll decrease it'll also remove so you don't have to pay for it.
Aurora AutoScaling
AWS RDS doesn't support autoscaling but you can always scale horizontally and vertically manually.
Scaling Your Amazon RDS Instance Vertically Horizontally

Terraform destroying RDS instance and retaining automated backups

I have created and I have been managing a Postgresql RDS instance using Terraform.
Assuming I perform a terraform destroy, will this also delete the associated RDS snapshots that have been taken via the RDS schedule?
Terraform added the option to keep the automated backups for an RDS with the delete_automated_backups flag. Just set this to false.
When destroying an RDS database you have the option to either create a long lived final snapshot or retain the automated backups which will be deleted as per the schedule they were set for:
Instead of creating a snapshot, you can choose to enable Retain automated backups when you delete a DB instance. These backups are still subject to the retention period of the DB instance and age out the same way systems snapshots do.
Terraform supports keeping a final snapshot by setting the final_snapshot_identifier and making sure that skip_final_snapshot is not set to true.
Unfortunately, Terraform doesn't currently support retaining the automated backups taken from scheduled snapshots but there is an open feature request with a couple of half finished pull requests linked to it.

What is the need of backup in Amazon RDS?

I have a doubt if in AWS all server-side work is done by cloud manager then why do we store backup for database?
I have studied in documentation that all the things are managed by cloud service providers for the database related things. Then what is the need of storing backup if service provider do everything for me?
You maintain your own backups of RDS instances for the same reason that you maintain offsite backups of on-premise databases: disaster recovery. In your own data center, a fire or terrorism or natural disaster could destroy both your database and your local backups. In the cloud, these disasters tend to take on a different form.
If all of your data is in any one place, then you are vulnerable to data loss in a catastrophic event, which could take a number of forms: a serious defect in the cloud provider's infrastructure (unlikely with AWS, but nothing is impossible), human error, malicious employees, a compromise of your credentials, or any other of a number of statistically-unlikely events -- the low probability of which becomes irrelevant when it occurs.
If you value your data, you back it up independently and outside of its native environment.
Amazon RDS runs a database of your choice: MySQL, PostgreSQL, Oracle, SQL Server. These are normal databases and operate in the same way as a database you would run yourself.
You are correct that a managed solution takes care of installation, maintenance and hardware issues. Also, you can configure the system to automatically take backups of the data.
From Working With Backups - Amazon Relational Database Service:
Amazon RDS creates and saves automated backups of your DB instance. Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases.
Amazon RDS creates automated backups of your DB instance during the backup window of your DB instance. Amazon RDS saves the automated backups of your DB instance according to the backup retention period that you specify. If necessary, you can recover your database to any point in time during the backup retention period.
You also have the ability to trigger a manual backup. This is advisable, for example, before you do major work on the database, such as modifying schemas when upgrading an application that uses the database.
Bottom line: Amazon RDS can manage the backups for you. You do not need to take manage the backup process, but you can trigger the RDS backups yourself.

Lambda RDS backups

I am working on a project that requires the automated backing up of two RDS instances. What would be the best way to accomplish this?
I was thinking to create a lambda function that backs up all RDS's with a tag 'Backup', similar to what I have going for EC2.
I appreciate any suggestions on how to accomplish this.
Here is a good example of an RDS maintenance Lambda for managing automated RDS backups from Lambda: https://github.com/cevoaustralia/aws-backup-lambda
As stated in the comments, RDS has a daily automated backup built into the service, but if you need a different or more frequent schedule, then you can use Lambda to automate the backups.
That project states:
A utility AWS lambda function to manage EBS and RDS snapshot backups.
The Lambda function takes new backups when executed, and manages the
deletion of the old ones when the upper limit is reached.
Beyond the RDS auto backups, a different/dedicated Lambda to copy snapshots is handy if you want to automate copying those snapshots to a different region for disaster recovery.
Using the above Lambda to schedule your snapshots, this Lambda will periodically copy the most current snapshot to another region, and prune old snapshots in the 'foreign' region. See https://github.com/pbudzon/aws-maintenance.
Also please see this answer on pros/cons of relying on RDS snapshots vs native backup: Should I stick only to AWS RDS Automated Backup or DB Snapshots?
RDS has automated snapshots, but you can copy those snapshots.
This tutorial shows how to automate the copy across regions, but could be easily modified to copy it to the same region.
It includes all the code needed as well as step by step instructions and a video walk through!
https://geektopia.tech/post.php?blogpost=Automating_The_Cross_Region_Copy_Of_RDS_Snapshots
RDS has automated backup out-of-the-box but this expire in 35 days so you can copy theses automated backups and its become manually without expire date. I wrote a article talking about this and I publish a project on github too
https://medium.com/#krisnamourt.filho/aws-rds-backup-strategy-f0cd1e0ac10f
https://github.com/krismorte/lambda-rds-snapshot
this is the example to copy rds snapshots
var cluster = await rdsFunc.describeClusters();
cluster.forEach(async (cluster)=>{
var snaps = await rdsFunc.describeClustersAutomatedSnapshot(cluster.DBClusterIdentifier)
if(snaps){
snaps.forEach(async (snap)=>{
var copyDate = dateFunc.minusDaysFromToday(daysBefore);
var snapshotDate = dateFunc.removeTimeFromDate(snap.SnapshotCreateTime);
if (copyDate == snapshotDate) {
var copy = await rdsFunc.copyClusterSnapshot(snap.DBClusterSnapshotIdentifier)
console.log(copy+" Rds cluster snapshot cloned")
}
})
}
})