Disabling AWS RDS backups when creating/updating instances? - amazon-web-services

I am creating new RDS MySQL instances from snapshots and updating their configurations both via the API and through the UI. Regardless of how I create or update instances, these actions automatically trigger new snapshots to be created through some kind of automatic backup process. Is there a way to disable snapshot creation when performing these actions since I do not need the additional snapshots and their creation is causing an unnecessary delay?

I spoke with AWS support and it looks like there is no way to prevent the backup being generated at instance creation time. This is due to how the backup creation on create/update is triggered (it is part of the automated backup process) and limited ability to control this feature (toggle it on and off, but only for existing instances).
Here are some more details in case anyone else runs into the same problems that I did.
I am interested in two scenarios:
Do not create a backup on a RestoreDBInstanceFromDBSnapshot request
Do not create a backup on a ModifyDBInstance request
The backups are controlled by this flag:
BackupRetentionPeriod = 0
Unfortunately this flag is part of an instance and of a snapshot, but can only be set on an instance. Therefore, in order to create an instance with this flag set (and thus no backup generated), the snapshot would have to have this flag disabled. This can only happen if the source instance had this flag disabled. At this point we could consider toggling the flag on the original instance when taking a snapshot, however disabling and re-enabling this flag has negative side effects, including:
There is a way to disable automatic backups for existing instances
however we highly discourage against this because it disables point-in-time
recovery. Once disabled, re-enabling them will only restore the backups
starting from the time you re-enable automatic backups.
We would lose all existing backups on the original instance. The end result is that there is not an effective way to avoid creating the first backup when an instance is created from a snapshot.
There is better news when updating an existing instance, since we can disable backups as part of the ModifyDBInstance request:
https://rds.amazonaws.com/
?Action=ModifyDBInstance
&DBInstanceIdentifier=mydbinstance
&BackupRetentionPeriod=0
Of course this still suffers from the loss of backups; however, my original purpose was to be able to create and modify snapshots of production databases, use them for a short period of time (hours), and then throw them away. Avoiding extraneous backup creation reduces overhead in this process.
Hopefully this information is useful to someone else!

If you create your RDS instance with Terraform using,
source = "github.com/terraform-aws-modules/terraform-aws-rds.git"
Although you must still set for example,
maintenance_window = "Mon:00:00-Mon:03:00"
backup_window = "03:00-06:00"
You can set
skip_final_snapshot= true
And the snapshot won't be created.
Shlomi

Related

Is there a way on aws rds to recover DB to a previous status on an existing instance?

We are setting up a testing environment and required the DB data is always cleaned before test.
I know we could always run a db cleanup SQL to do so. But still, need to spend on maintaining SQLs when db updated.
I'd like to know if RDS provides any solutions to recover an existing instance to a previous status? (like apply certain volume)
Checked some docs on AWS, found restore features but say it can only be applied to new instance.
Any ideas?

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.

RDS incremental backup

We are trying to take incremental back for mysql in RDS. We are unable to find any methods to take incremental backup . How can this be done in RDS ? In FAQ we read that we can restore the data up to last five minutes. But we are not sure how to do that?
You can use AWS Data Pipeline to do this.
It supports full RDS dump or incremental dump and restore.The problem is you cannot reuse a pipeline. You will have to clone the pipeline and create a new one using AWS Lambda or Jenkins or some other job scheduling system each time you want to create a Backup or Restore.
Check out this blog to find more information on that.
a. RDS provides Native incremental backup feature - RDS snapshots and also has a feature called Point in time recovery (PITR). This allows you to restore a state of RDS instance from last 5 minutes upto max 35 days in the past (35 days being the max automatic backup retention period).
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html
b. You can also trigger Manual snapshots in RDS - which is once again incremental (which means that if you have a running RDS server of 1TB your first/base snapshot will be 1TB) and any subsequent snapshots of the same server will only capture the modified blocks. In manual snapshots there is not retention period. You can keep as long as you wish unless you want to delete it manually. But the PITR feature is not available over Manual snapshots (i.e not longer than the configured automatic backup retention window)
In both the above features, you are dependent upon the RDS API/platform to take backup, list all the backups and restore RDS from backup. You dont have any control over the raw data / row level data.
For raw data backup, you need to consider Mysqldumps and restore - but that is an expensive operation (both backup and restore). You can use some third party tools like (percona) which provides good utilities to perform the same - but you cant use few tools because RDS does not allows you with RDS host access - so unless you run your own Mysql on VM/EC2, you are limited to the above 2 options. hope this helps.
https://www.percona.com/doc/percona-xtrabackup/2.3/innobackupex/incremental_backups_innobackupex.html
https://www.percona.com/doc/percona-xtrabackup/2.3/backup_scenarios/incremental_backup.html

Getting Specific Data from RDS Automated backup

I have an RDS automated backup from several hours ago. In there is some data, which I have accidentally removed from the current database. Is it possible to extract data from an old automated backup?
Yes, assuming the data was present at your recovery time.
If you used the automated backup feature, you will be able to restore a DB instance to a specified time -- this process will create a new DB instance that uses the data from your backup. Here's a detailed explaination of what would be happening:
The automated backup feature of Amazon RDS enables point-in-time recovery of your DB Instance. When automated backups are turned on for your DB Instance, Amazon RDS automatically performs a full daily snapshot of your data (during your preferred backup window) and captures transaction logs (as updates to your DB Instance are made). When you initiate a point-in-time recovery, transaction logs are applied to the most appropriate daily backup in order to restore your DB Instance to the specific time you requested.
You haven't told us what type of database engine you're using... but very generally, once the new DB instance is in the available state, you will be able to connect to it and extract any data just as you would on the source DB instance.
You can perform this action from the:
AWS console
CLI (rds-restore-db-instance-to-point-in-time)
API (RestoreDBInstanceToPointInTime).
Note that the security group will be set to the "Default" group by default, so you may need to modify the DB instance after it becomes available if you use any custom security groups to connect.

RDS - Why is a backup created on creation

I am working with RDS and I have noticed that when I create the database it seems to create an automated snapshot.
I can understand this when the instance is being shutdown by why is one made when the database is actually created, and is there any way to stop this from happening?
You can set the instance's backup retention period to 0 which will disable backups. However, as far as I know there is no way to create an instance in this state.
RDS uses this snapshot along with the MySQL binary log (or equivalent for other dbs) to provide point in time recovery with 5 minute granularity, as well as restoring the whole snapshot.
This is RDS doing a backup for you. It defaults to every 30 minutes, but it can be increased up to every 3 hours. You are not able to disable this as it is core functionality for RDS's disaster recovery implementation so that the database can be restored to a 30 minute relative point in time whenever necessary.