Managing automated backups - Amazon Relational Database Service

Managing automated backups

This section shows how to manage automated backups for DB instances and DB clusters.

Backup window

Automated backups occur daily during the preferred backup window. If the backup requires more time than allotted to the backup window, the backup continues after the window ends until it finishes. The backup window can't overlap with the weekly maintenance window for the DB instance or Multi-AZ DB cluster.

During the automatic backup window, storage I/O might be suspended briefly while the backup process initializes (typically under a few seconds). You might experience elevated latencies for a few minutes during backups for Multi-AZ deployments. For MariaDB, MySQL, Oracle, and PostgreSQL, I/O activity isn't suspended on your primary during backup for Multi-AZ deployments because the backup is taken from the standby. For SQL Server, I/O activity is suspended briefly during backup for both Single-AZ and Multi-AZ deployments because the backup is taken from the primary. For Db2, I/O activity is also suspended briefly during backup even though the backup is taken from the standby.

Automated backups might occasionally be skipped if the DB instance or cluster has a heavy workload at the time a backup is supposed to start. If a backup is skipped, you can still do a point-in-time-recovery (PITR), and a backup is still attempted during the next backup window. For more information on PITR, see Restoring a DB instance to a specified time.

If you don't specify a preferred backup window when you create the DB instance or Multi-AZ DB cluster, Amazon RDS assigns a default 30-minute backup window. This window is selected at random from an 8-hour block of time for each AWS Region. The following table lists the time blocks for each AWS Region from which the default backup windows are assigned.

Region Name Region Time Block
US East (Ohio) us-east-2 03:00–11:00 UTC
US East (N. Virginia) us-east-1 03:00–11:00 UTC
US West (N. California) us-west-1 06:00–14:00 UTC
US West (Oregon) us-west-2 06:00–14:00 UTC
Africa (Cape Town) af-south-1 03:00–11:00 UTC
Asia Pacific (Hong Kong) ap-east-1 06:00–14:00 UTC
Asia Pacific (Hyderabad) ap-south-2 06:30–14:30 UTC
Asia Pacific (Jakarta) ap-southeast-3 08:00–16:00 UTC
Asia Pacific (Melbourne) ap-southeast-4 11:00–19:00 UTC
Asia Pacific (Mumbai) ap-south-1 16:30–00:30 UTC
Asia Pacific (Osaka) ap-northeast-3 00:00–08:00 UTC
Asia Pacific (Seoul) ap-northeast-2 13:00–21:00 UTC
Asia Pacific (Singapore) ap-southeast-1 14:00–22:00 UTC
Asia Pacific (Sydney) ap-southeast-2 12:00–20:00 UTC
Asia Pacific (Tokyo) ap-northeast-1 13:00–21:00 UTC
Canada (Central) ca-central-1 03:00–11:00 UTC
Canada West (Calgary) ca-west-1 18:00–02:00 UTC
China (Beijing) cn-north-1 06:00–14:00 UTC
China (Ningxia) cn-northwest-1 06:00–14:00 UTC
Europe (Frankfurt) eu-central-1 20:00–04:00 UTC
Europe (Ireland) eu-west-1 22:00–06:00 UTC
Europe (London) eu-west-2 22:00–06:00 UTC
Europe (Milan) eu-south-1 02:00–10:00 UTC
Europe (Paris) eu-west-3 07:29–14:29 UTC
Europe (Spain) eu-south-2 02:00–10:00 UTC
Europe (Stockholm) eu-north-1 23:00–07:00 UTC
Europe (Zurich) eu-central-2 02:00–10:00 UTC
Israel (Tel Aviv) il-central-1 03:00–11:00 UTC
Middle East (Bahrain) me-south-1 06:00–14:00 UTC
Middle East (UAE) me-central-1 05:00–13:00 UTC
South America (São Paulo) sa-east-1 23:00–07:00 UTC
AWS GovCloud (US-East) us-gov-east-1 17:00–01:00 UTC
AWS GovCloud (US-West) us-gov-west-1 06:00–14:00 UTC

Backup retention period

You can set the backup retention period when you create a DB instance or Multi-AZ DB cluster. If you don't set the backup retention period, the default backup retention period is one day if you create the DB instance using the Amazon RDS API or the AWS CLI. The default backup retention period is seven days if you create the DB instance using the console.

After you create a DB instance or cluster, you can modify the backup retention period. You can set the backup retention period of a DB instance to between 0 and 35 days. Setting the backup retention period to 0 disables automated backups. You can set the backup retention period of a multi-AZ DB cluster to between 1 and 35 days. Manual snapshot limits (100 per Region) don't apply to automated backups.

Automated backups aren't created while a DB instance or cluster is stopped. Backups can be retained longer than the backup retention period if a DB instance has been stopped. RDS doesn't include time spent in the stopped state when the backup retention window is calculated.

Important

An outage occurs if you change the backup retention period from 0 to a nonzero value or from a nonzero value to 0. This applies to both Single-AZ and Multi-AZ DB instances.

Enabling automated backups

If your DB instance doesn't have automated backups enabled, you can enable them at any time. You enable automated backups by setting the backup retention period to a positive nonzero value. When automated backups are turned on, your DB instance is taken offline and a backup is immediately created.

Note

If you manage your backups in AWS Backup, you can't enable automated backups. For more information, see Using AWS Backup to manage automated backups.

To enable automated backups immediately
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB instance or Multi-AZ DB cluster that you want to modify.

  3. Choose Modify.

  4. For Backup retention period, choose a positive nonzero value, for example 3 days.

  5. Choose Continue.

  6. Choose Apply immediately.

  7. Choose Modify DB instance or Modify cluster to save your changes and enable automated backups.

To enable automated backups, use the AWS CLI modify-db-instance or modify-db-cluster command.

Include the following parameters:

  • --db-instance-identifier (or --db-cluster-identifier for a Multi-AZ DB cluster)

  • --backup-retention-period

  • --apply-immediately or --no-apply-immediately

In the following example, we enable automated backups by setting the backup retention period to three days. The changes are applied immediately.

For Linux, macOS, or Unix:

aws rds modify-db-instance \ --db-instance-identifier mydbinstance \ --backup-retention-period 3 \ --apply-immediately

For Windows:

aws rds modify-db-instance ^ --db-instance-identifier mydbinstance ^ --backup-retention-period 3 ^ --apply-immediately

To enable automated backups, use the RDS API ModifyDBInstance or ModifyDBCluster operation with the following required parameters:

  • DBInstanceIdentifier or DBClusterIdentifier

  • BackupRetentionPeriod

Viewing automated backups

To view your automated backups, choose Automated backups in the navigation pane. To view individual snapshots associated with an automated backup, choose Snapshots in the navigation pane. Alternatively, you can describe individual snapshots associated with an automated backup. From there, you can restore a DB instance directly from one of those snapshots.

To describe the automated backups for your existing DB instances using the AWS CLI, use one of the following commands:

aws rds describe-db-instance-automated-backups --db-instance-identifier DBInstanceIdentifier

or

aws rds describe-db-instance-automated-backups --dbi-resource-id DbiResourceId

To describe the retained automated backups for your existing DB instances using the RDS API, call the DescribeDBInstanceAutomatedBackups action with one of the following parameters:

  • DBInstanceIdentifier

  • DbiResourceId

Retaining automated backups

Note

You can only retain automated backups of DB instances, not Multi-AZ DB clusters.

When you delete a DB instance, you can choose to retain automated backups. Automated backups can be retained for a number of days equal to the backup retention period configured for the DB instance at the time when you delete it.

Retained automated backups contain system snapshots and transaction logs from a DB instance. They also include your DB instance properties like allocated storage and DB instance class, which are required to restore it to an active instance.

Retained automated backups and manual snapshots incur billing charges until they're deleted. For more information, see Retention costs.

You can retain automated backups for RDS instances running the Db2, MariaDB, MySQL, PostgreSQL, Oracle, and Microsoft SQL Server engines.

You can restore or remove retained automated backups using the AWS Management Console, RDS API, and AWS CLI.

Retention period

The system snapshots and transaction logs in a retained automated backup expire the same way that they expire for the source DB instance. Because there are no new snapshots or logs created for this instance, the retained automated backups eventually expire completely. Effectively, they live as long their last system snapshot would have done, based on the settings for retention period the source instance had when you deleted it. Retained automated backups are removed by the system after their last system snapshot expires.

You can remove a retained automated backup in the same way that you can delete a DB instance. You can remove retained automated backups using the console or the RDS API operation DeleteDBInstanceAutomatedBackup.

Final snapshots are independent of retained automated backups. We strongly suggest that you take a final snapshot even if you retain automated backups because the retained automated backups eventually expire. The final snapshot doesn't expire.

Viewing retained backups

To view your retained automated backups, choose Automated backups in the navigation pane, then choose Retained. To view individual snapshots associated with a retained automated backup, choose Snapshots in the navigation pane. Alternatively, you can describe individual snapshots associated with a retained automated backup. From there, you can restore a DB instance directly from one of those snapshots.

To describe your retained automated backups using the AWS CLI, use the following command:

aws rds describe-db-instance-automated-backups --dbi-resource-id DbiResourceId

To describe your retained automated backups using the RDS API, call the DescribeDBInstanceAutomatedBackups action with the DbiResourceId parameter.

Restoration

For information on restoring DB instances from automated backups, see Restoring a DB instance to a specified time.

Retention costs

The cost of a retained automated backup is the cost of total storage of the system snapshots that are associated with it. There is no additional charge for transaction logs or instance metadata. All other pricing rules for backups apply to restorable instances.

For example, suppose that your total allocated storage of running instances is 100 GB. Suppose also that you have 50 GB of manual snapshots plus 75 GB of system snapshots associated with a retained automated backup. In this case, you are charged only for the additional 25 GB of backup storage, like this: (50 GB + 75 GB) – 100 GB = 25 GB.

Limitations

The following limitations apply to retained automated backups:

  • The maximum number of retained automated backups in one AWS Region is 40. It's not included in the DB instances quota. You can have 40 running DB instances and an additional 40 retained automated backups at the same time.

  • Retained automated backups don't contain information about parameters or option groups.

  • You can restore a deleted instance to a point in time that is within the retention period at the time of deletion.

  • You can't modify a retained automated backup. That's because it consists of system backups, transaction logs, and the DB instance properties that existed at the time that you deleted the source instance.

Deleting retained automated backups

You can delete retained automated backups when they are no longer needed.

To delete a retained automated backup
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Automated backups.

  3. On the Retained tab, choose the retained automated backup that you want to delete.

  4. For Actions, choose Delete.

  5. On the confirmation page, enter delete me and choose Delete.

You can delete a retained automated backup by using the AWS CLI command delete-db-instance-automated-backup with the following option:

  • --dbi-resource-id – The resource identifier for the source DB instance.

    You can find the resource identifier for the source DB instance of a retained automated backup by running the AWS CLI command describe-db-instance-automated-backups.

The following example deletes the retained automated backup with source DB instance resource identifier db-123ABCEXAMPLE.

For Linux, macOS, or Unix:

aws rds delete-db-instance-automated-backup \ --dbi-resource-id db-123ABCEXAMPLE

For Windows:

aws rds delete-db-instance-automated-backup ^ --dbi-resource-id db-123ABCEXAMPLE

You can delete a retained automated backup by using the Amazon RDS API operation DeleteDBInstanceAutomatedBackup with the following parameter:

  • DbiResourceId – The resource identifier for the source DB instance.

    You can find the resource identifier for the source DB instance of a retained automated backup using the Amazon RDS API operation DescribeDBInstanceAutomatedBackups.

Disabling automated backups

You might want to temporarily disable automated backups in certain situations, for example while loading large amounts of data.

Important

We highly discourage disabling automated backups because it disables point-in-time recovery. Disabling automatic backups for a DB instance or Multi-AZ DB cluster deletes all existing automated backups for the database. If you disable and then re-enable automated backups, you can restore starting only from the time you re-enabled automated backups.

To disable automated backups immediately
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB instance or Multi-AZ DB cluster that you want to modify.

  3. Choose Modify.

  4. For Backup retention period, choose 0 days.

  5. Choose Continue.

  6. Choose Apply immediately.

  7. Choose Modify DB instance or Modify cluster to save your changes and disable automated backups.

To disable automated backups immediately, use the modify-db-instance or modify-db-cluster command and set the backup retention period to 0 with --apply-immediately.

The following example immediately disables automatic backups on a Multi-AZ DB cluster.

For Linux, macOS, or Unix:

aws rds modify-db-cluster \ --db-cluster-identifier mydbcluster \ --backup-retention-period 0 \ --apply-immediately

For Windows:

aws rds modify-db-cluster ^ --db-cluster-identifier mydbcluster ^ --backup-retention-period 0 ^ --apply-immediately

To know when the modification is in effect, call describe-db-instances for the DB instance (or describe-db-clusters for a Multi-AZ DB cluster) until the value for backup retention period is 0 and mydbcluster status is available.

aws rds describe-db-clusters --db-cluster-identifier mydcluster

To disable automated backups immediately, call the ModifyDBInstance or ModifyDBCluster operation with the following parameters:

  • DBInstanceIdentifier = mydbinstance (or DBClusterIdentifier = mydbcluster)

  • BackupRetentionPeriod = 0

https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=mydbinstance &BackupRetentionPeriod=0 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T17%3A48%3A21.746Z &AWSAccessKeyId=<&AWS; Access Key ID> &Signature=<Signature>

Automated backups with unsupported MySQL storage engines

For the MySQL DB engine, automated backups are only supported for the InnoDB storage engine. Using these features with other MySQL storage engines, including MyISAM, can lead to unreliable behavior when you're restoring from backups. Specifically, since storage engines like MyISAM don't support reliable crash recovery, your tables can be corrupted in the event of a crash. For this reason, we encourage you to use the InnoDB storage engine.

  • To convert existing MyISAM tables to InnoDB tables, you can use the ALTER TABLE command, for example: ALTER TABLE table_name ENGINE=innodb, ALGORITHM=COPY;

  • If you choose to use MyISAM, you can attempt to manually repair tables that become damaged after a crash by using the REPAIR command. For more information, see REPAIR TABLE statement in the MySQL documentation. However, as noted in the MySQL documentation, there is a good chance that you might not be able to recover all your data.

  • If you want to take a snapshot of your MyISAM tables before restoring, follow these steps:

    1. Stop all activity to your MyISAM tables (that is, close all sessions).

      You can close all sessions by calling the mysql.rds_kill command for each process that is returned from the SHOW FULL PROCESSLIST command.

    2. Lock and flush each of your MyISAM tables. For example, the following commands lock and flush two tables named myisam_table1 and myisam_table2:

      mysql> FLUSH TABLES myisam_table, myisam_table2 WITH READ LOCK;
    3. Create a snapshot of your DB instance or Multi-AZ DB cluster. When the snapshot has completed, release the locks and resume activity on the MyISAM tables. You can release the locks on your tables using the following command:

      mysql> UNLOCK TABLES;

    These steps force MyISAM to flush data stored in memory to disk, which ensures a clean start when you restore from a DB snapshot. For more information on creating a DB snapshot, see Creating a DB snapshot for a Single-AZ DB instance.

Automated backups with unsupported MariaDB storage engines

For the MariaDB DB engine, automated backups are only supported with the InnoDB storage engine. Using these features with other MariaDB storage engines, including Aria, can lead to unreliable behavior when you're restoring from backups. Even though Aria is a crash-resistant alternative to MyISAM, your tables can still be corrupted in the event of a crash. For this reason, we encourage you to use the InnoDB storage engine.

  • To convert existing Aria tables to InnoDB tables, you can use the ALTER TABLE command. For example: ALTER TABLE table_name ENGINE=innodb, ALGORITHM=COPY;

  • If you choose to use Aria, you can attempt to manually repair tables that become damaged after a crash by using the REPAIR TABLE command. For more information, see http://mariadb.com/kb/en/mariadb/repair-table/.

  • If you want to take a snapshot of your Aria tables before restoring, follow these steps:

    1. Stop all activity to your Aria tables (that is, close all sessions).

    2. Lock and flush each of your Aria tables.

    3. Create a snapshot of your DB instance or Multi-AZ DB cluster. When the snapshot has completed, release the locks and resume activity on the Aria tables. These steps force Aria to flush data stored in memory to disk, thereby ensuring a clean start when you restore from a DB snapshot.