Backing up and Restoring a MySQL HeatWave Instance with the OCI CLI

This is the third post in a series dedicated to showing how to use the OCI CLI to manage MySQL HeatWave resources. In this post, we will discuss how to create a backup of a MySQL HeatWave instance and create a new MySQL HeatWave instance from that backup.
Prerequisites
Before you can run any of the examples below, you need to install the OCI CLI. If you do not have the CLI installed, follow the instructions here to install and configure the CLI.
Creating the Backup
Generating Command JSON
As we did in this post, we are first going to create a JSON file of all the possible options for creating a backup. The command to create this JSON file is:
The file backup-create.json
will resemble:
I will update this file only to contain the information we want to create a new backup.
Here, we set backupType
as INCREMENTAL
, displayName
as OCI CLI Backup Demo
, and retentionInDays
as 42
. The dbSystemId
is the OCID of the MySQL HeatWave instance we wish to back up. Lastly, we tell the CLI to wait until the command state is SUCCEEDED
before returning any information. The command may return as SUCCEEDED
before the backup is completed.
Run the Command
To create a new backup using this JSON config file, we run the command:
When we run this command, we will see the following text in the command/terminal window:
Once the command has reached a state of SUCCEEDED
, we will see more information about the backup:
Restoring a Backup
To create a new MySQl HeatWave instance from this backup (or any other backup), we use the oci mysql db-system clone
command.
Generating Command JSON
Let’s take another look at the commands available when creating a MySQL HeatWave instance by running the command:"
The file backup-restore.json
will look like the following:
Once again, I will trim this down to include only the properties we will use. Here is what my new file looks like.
Run the Command
To create a new backup using this JSON config file, we run the command:
When we run this command, we will see the following text in the command/terminal window:
Once the command has reached a state of SUCCEEDED
, we will see more information about the new MySQL HeatWave instance:
Remember, the command may return as a SUCCEEDED
state before the new instance is available. Once the instance shows as ACTIVE,
you can start using it.
Wrap-up
The OCI CLI gives us tools to manage MySQL HeatWave instances, including manually creating a backup and restoring any backup to a new MySQL HeatWave instance. Additional commands allow us to update information about a backup and manage replicas and replication channels. We will cover some of this functionality in future posts.
Photo by Kyle Bushnell on Unsplash