Delete a database
Delete a database and everything it holds, or keep its backups for the retention period with a final backup.
Replace ewdb-0123456789ab with your database's id.
Warning
Without a final backup, nothing is kept: the backups go with the database, including the ones you took with Back up now, and a deleted database cannot be restored from.
Prerequisites
- Permission for
rds:DeleteDBInstance; to change deletion protection,rds:ModifyDBInstance. - Deletion protection off. While it is on, a delete is refused with
400"Deletion protection is enabled. Disable it before deleting." In the console, Delete database stays disabled. - For a final backup: a database in status
availablewith backups on (retention above 0 days). Otherwise the request is refused with409before anything is deleted: "Backups are off for this database, so there is nothing to keep a final backup in." or "A final backup needs the database running; it is status." A final backup of a database already deleted with one is refused with400. - In the console, also
rds:DescribeDBInstancesto open the database's page (without it the page is not found).
Turn deletion protection on or off
- Open the database, then choose Danger zone.
- Turn Deletion protection on or off. The change is saved at once.
dcloud rds instances set-deletion-protection ewdb-0123456789ab --enabledTo turn it off: --no-enabled.
PATCH /rds/api/instances/ewdb-0123456789ab/deletion-protection
{ "enabled": true }resource "dcloud_db_instance" "orders" {
identifier = "orders"
instance_class = "performance-2"
deletion_protection = true
}You can also turn it on at creation (deletionProtection: true).
Delete the database
- Open the database, then choose Danger zone (or, in the ⋯ menu, Delete database…).
- Under Delete this database, select or clear Take a final backup and keep the backups for
N days. The check box is there, and selected, only while the database is
availablewith backups on. - Choose Delete database.
- In the dialog, enter the database name, and choose Delete database.
The dialog says what is removed and what is kept, and what keeping the backups costs. The console returns to the database list.
dcloud rds instances delete ewdb-0123456789ab --final-backup trueDELETE /rds/api/instances/ewdb-0123456789ab?finalBackup=trueWithout ?finalBackup=true, nothing is kept.
Remove the dcloud_db_instance resource and run terraform apply. Terraform deletes without a final
backup.
Result
The request answers with the status deleting. Branch pools of the database, and their branches,
are deleted with it.
Without a final backup, the machines, their volumes, the private address (a cluster's internal network; your own network stays), the firewall, for a cluster the load balancer, the master password and login passwords in Secrets and the backup repository in object storage are all removed.
With a final backup:
- A full backup is taken first and waited for, for up to two hours. If it fails or takes longer,
nothing is deleted: the database is
availableagain, and Activity says "Not deleted: the final backup … The database is available again." - The machines, volumes, address, firewall and load balancer are then removed. The backups, their encryption key, the master password and the login passwords are kept.
- The database stays listed under its own name with status Deleted, backups kept and the date
they go, for its backup retention period (
backupRetentionDays, at least one day, counted from the final backup). Its page has Backups, Activity and Danger zone only, and All resources lists it the same way. In the API its status isretainedand its identifier gets a-deleted-…suffix, so the original name is free at once; the console shows the original name and asks for it to remove the backups.
Every backup of the window is kept, and the ones you took with Back up now stay until you
delete them (on databases that keep them; see Back up a database). Backup
storage up to the database's allocated size is free; beyond it, the backup rate per GiB-month
(rds.backup.gb_month).
Restore from it like any database (see Restore a database): to the final backup, or to any moment its backups still cover. When the retention period ends, the backups and the row are removed, unless it still holds backups taken with Back up now: then it stays until you delete those. To remove everything sooner, delete the retained database again (Remove the kept backups, then Remove backups); that removes everything at once.
The backup repository is the database's own bucket, and deleting the database empties and deletes it. A delete that failed before it reached storage does not leave the bucket behind for good: every ten minutes the platform removes any bucket of this installation that no database claims and that is older than an hour.