11 Backup, Restore and Recover Databases

Review backup, restore, and recovery operations for your databases.

About Database Backup, Restore and Recover

Backup your databases in Oracle Database Appliance and use the restore and recover features to restore a database to another system or to recover database files.

It is important to create a backup recovery strategy to protect the databases in Oracle Database Appliance from data loss due to a physical problem with a disk that causes a failure of a read from or write to a disk file that is required to run the database, or due to user error. You can create a backup policy in the Web Console or from the command-line interface.

The following backup options are available:

  • Backup to an Oracle Fast Recovery Area (FRA) disk

  • Backup to Oracle Cloud Infrastructure Object Storage (Oracle Object Storage)

You cannot use the backup, restore, and recovery features with a third-party repository.

The backup feature enables you to create a backup configuration with your backup parameters, including backup level and location. For new and existing databases, you can create and attach a backup configuration to a database to perform a daily backup. Once a backup configuration is attached to a database, the dcs-agent schedules daily automatic backups for the database. The default schedule is a level 0 backup every Sunday and a level 1 backup Monday through Saturday. You can edit or disable the schedule.

The dcs-agent generates and saves a backup report for each backup. The backup report contains the metadata required to recover or restore a database.

Note:

You cannot backup databases that use Transparent Data Encryption (TDE).

Recovering a database in Oracle Database Appliance is a full RMAN database recovery. You can recover from a Backup Report, a point-in-time (PITR), a System Change Number (SCN), or from the latest backup.

Backup Configuration

The Backup Configuration defines the backup details. When you create a Backup Configuration, you define the destination for the database backups, either Disk or Cloud Object Storage, and you define the attributes such as the backup level and the recovery window.

If you use the Oracle Object Storage for backup and recovery, you must have an ObjectStore Resource ID.

You assign the backup configuration to the database when you create the database. You can attach a backup configuration to an existing database or edit a backup configuration.

Backup Levels

The backup configuration that you create defines the backup level:

  • Level 0: The backup captures all blocks in the datafile. By default level 0 backups occur every Sunday. A level 0 backup is a full backup and is used as the parent for a level 1 backup.

  • Level 1: The backup is an incremental backup that captures only those blocks that change between backups in each datafile. By default, a level 1 backup occurs daily, Monday through Saturday, and captures images of each block in a datafile that changed. Level 1 backups are differential backups. The backup includes blocks from the most recent previous level 1 or level 0 backup.

  • LongTerm: The backup is a long-term, or archival backup. Use LongTerm to create a backup that is all-inclusive and exempt from the backup retention policy. The backup is all-inclusive because every file needed to restore and recover the database is backed up to a single location. The backup is exempt from the retention policy that is defined in the recovery window. You must use Oracle Object Storage for long term backups.

The AutoScheduler creates a level 0 backup on Sunday and level 1 on the remaining days of the week. You can display a list of scheduled backups, edit your backup schedule, or disable a scheduled backup.

Backup to Disk

When you backup to disk, you are using the Oracle Fast Recovery Area (FRA) of the disk. FRA is a storage directory that allows backup and recovery operations on Oracle databases. The directory contains archived redo logs, backup pieces and copies, and the control file.

Advantages to backing up to disk are as follows:

  • Quick recovery from backups stored on disk

  • Ability to flashback the database

  • Automate management of recovery related files (like archived logs)

Note:

When you backup to disk, data is not encrypted and passwords are not allowed. In addition, backup to disk requires a lot of disk space (up to two to three times the size of the database).

The following is a high-level overview of the workflow for backup and recovery when using a disk:

  1. Create a backup configuration to define the backup location (disk), backup level, and recovery window.

  2. Create a database and attach the backup configuration as part of creating the database. When the backup configuration is associated with a database, backups are automatically created.

  3. Manage obsolete backups.

  4. Recover the database from a backup on the disk.

Backup to Oracle Object Storage

Oracle Object Storage is a highly secure, scalable storage platform that enables you to safely and securely store or retrieve a database backup at any time. Data and the associated metadata are stored as an object in a logical container (bucket). Oracle Database Appliance creates a Backup Report and a unique ID to identify each backup.

Oracle Object Storage is tightly integrated with Oracle Cloud Infrastructure Identity and Access Management. The data, user-defined metadata associated with the data, and encryption keys are automatically encrypted using 256-bit Advanced Encryption Standard (AES- 256). The encryption keys are rotated frequently and cannot be disabled. By default, only authenticated users that have explicitly been granted access to specific resources can access data stored in Oracle Object Storage. Data is uploaded and downloaded over SSL endpoints using the HTTPS protocol.

When you backup to Oracle Object Storage, you are using your backup configuration and your Oracle ObjectStoreSwift credentials. The credentials are stored in an encrypted Oracle wallet. You can attach the credentials to one or more backup configurations.

Note:

Credentials are validated when you create the backup configuration that uses Oracle Object Storage. The credentials are not validated against the URL and tenancy.

Advantages to using Oracle Object Storage are as follows:

  • Backups are encrypted using the password for non-TDE databases.

    Note:

    Save the password that you use during backups in a safe location, you must provide the password during recovery operations.
  • Quick recovery from backups. With the Oracle Object Storage, you can safely and securely use the Web Console to store or retrieve data directly from within the cloud platform, at any time. 

  • Automate management of recovery related files (like archived logs)

  • Oracle Object Storage is not directly accessed by the operating system, instead it uses APIs to access the storage at the application level.

The following is a high-level overview of the workflow for backup and recovery when using Oracle Object Storage:

  1. Create a ObjectStoreSwift object with your credentials.

  2. Create a backup configuration to define the backup location (ObjectStore), resource id of ObjectStoreSwift, the container (bucket) name where you want to store backups, and the recovery window.

  3. Create a database and attach the backup configuration as part of creating the database. When the backup configuration is associated with a database, backups are automatically created.

  4. Manage obsolete backups.

  5. Restore from backup. When you save your backups to Oracle Object Storage, you can restore the database to the same system or to a different system.

  6. Recover the database from a backup on Oracle Object Storage.

Note:

Before you can use this backup option, you must create an Oracle Cloud Infrastructure Object Storage account. When you create the account, you define the account credentials, end point URL, and bucket. Go to the Oracle Store and sign up for Oracle Cloud Infrastructure Object Storage.

Backup Reports

A backup report is generated for each backup and is similar to, but does not replace, a recovery catalog. The report contains the Oracle Database Appliance information and metadata needed to restore or recover a database. The Backup Report is designed to keep track of all of the information required to restore or recover a database.

The following is an example of a level 1 backup report:

{
  "id" : "2d82460c-d648-4e75-8c7d-72cc90bc442a",
  "dbResId" : "b5fc646e-01a6-4c8b-8286-7633346c4329",
  "tag" : null,
  "dbId" : "2717054291",
  "dbName" : "HRDbO",
  "dbUniqueName" : "HRDbOu",
  "backupType" : "REGULAR-L1",
  "keepDays" : null,
  "backupLocation" : "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/dbaasimage/backupbucket",
  "cfBackupHandle" : "c-2717054291-20171108-04",
  "spfBackupHandle" : "c-2717054291-20171108-04",
  "pitrTimeStamp" : "November 08, 2017 12:43:14 PM UTC",
  "pitrSCN" : "1175058",
  "resetLogsTimeStamp" : "November 08, 2017 09:55:34 AM UTC",
  "resetLogsSCN" : "1112268",
  "oraHomeVersion" : "12.2.0.1.170814 (26723265, 26609817)",
  "sqlPatches" : "25811364,26609817",
  "backupLogLoc" : "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/dbaasimage/backupbucket/scaoda702c1n1/rmanlog/HRDbOu/2717054291/2017-11-08/rman_backup_2017-11-08_12-42-41.0545.log",
  "tdeWalletLoc" : null,
  "dbConfigLoc" : "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/dbaasimage/backupbucket/scaoda702c1n1/dbconfig/HRDbOu/2717054291/2017-11-08/DBCONFIG_TAG20171108T124407_2017-11-08_12-44-07.0533.tar.gz",
  "name" : "Backup_Report_HRDbO",
  "createTime" : "November 08, 2017 12:42:08 PM UTC",
  "state" : {
    "status" : "CONFIGURED"
  },
  "updatedTime" : "November 08, 2017 12:44:12 PM UTC",
  "backupReportLogDetail" : "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/dbaasimage/backupbucket/scaoda702c1n1/rmandetaillogreport/HRDbOu/2717054291/2017-11-08/rman_list_backup_detail_2017-11-08_12-44-04.0362.log",
  "dbInfo" : {
    "dbClass" : "OLTP",
    "dbType" : "RAC",
    "dbShape" : "odb1",
    "dbEdition" : "EE",
    "dbStorage" : "ASM"
  },
  "dbDataSize" : "1542M",
  "dbRedoSize" : "16403M"
}

About Recovery Options

The recovery in Oracle Database Appliance always performs a full database restore or recover. The recovery options are LATEST, PITR, SCN, and BackupReport.

The following types of recovery are available:

  • LATEST: Performs a complete recovery (valid backups and all required archived logs and online redo logs must be available)

  • PITR: Point-in-Time Recovery that performs a recovery to a specified timestamp within the current incarnation of database

  • SCN: SCN-based recovery that performs a recovery is an incomplete recovery to a specified SCN within the current incarnation of database.

  • BackupReport: Performs a recovery based on the Backup Report timestamp. The BackupReport option is similar to PITR, except that the recovery uses the Backup Report timestamp instead of a specified timestamp.

Point-in-Time Database Recovery

Point-in-Time Recovery (PITR) recovers the database to a specific point-in-time. You can use a timestamp or a backup report for this type of recovery.

A point-in-time recovery is often used for the following situations:

  • A user error or corruption removes needed data or introduces corrupted data. For example, someone erroneously deletes or updates the contents of one or more tables, drops database objects that are still needed during an update to an application, or runs a large batch update that fails midway.

  • A database upgrade fails.

System Change Number Recovery

A system change number (SCN) is a stamp that defines a committed version of a database at a point in time. Oracle assigns every committed transaction a unique SCN. You can recover a database to the latest time or to an SCN.

The database is restored from backups created before the target time, and then applies incremental backups and logs to re-create all changes between the time of the data file backups and the end point of recovery. When the end point is specified as an SCN, the database applies the redo logs and stops after each redo thread or the specified SCN, whichever occurs first. When the end point is specified as a time, the database internally determines a suitable SCN for the specified time and then recovers to this SCN.

SCN is a primary mechanism to maintain data consistency in Oracle database. With each execution, there is an increase in the count of the SCN. The following are some examples of areas that use SCN:

  1. Redo records. Every redo record has an SCN version of the redo record in the redo header (redo records can have non-unique SCN). Given redo records from two threads (as in the case of RAC), recovery will order them in SCN order, essentially maintaining a strict sequential order.

  2. Data block. Every data block has block SCN (block version). In addition to that, a change vector in a redo record also has expected block SCN. This means that a change vector can be applied to one and only version of the block. Code checks if the target SCN in a change vector is matching with the block SCN before applying the redo record. If there is a mismatch, corruption errors are thrown.

  3. Read consistency. Every query has query environment which includes an SCN at the start of the query. A session can see the transactional changes only if that transaction commit SCN is lower then the query environment SCN.

  4. Commit. Every commit generates an SCN (commit SCN) that marks a transaction boundary. Group commits are possible too.

Obsolete Database Backups

It is important to remove older backups once they become obsolete. The type of backup and the recovery window that you define in the database backup configuration determines when obsolete database backups are deleted.

For level 0 and level 1 backups, run the command odacli delete-backup for a given Database Resource Identifier to delete obsolete backups based on the defined recovery window.

For Longterm backups, create a JSON input file and use the command odacli delete-backup for a given Backup Report to delete the backups from Oracle Object Storage.

Typically, older level 0 and level 1 database backups are considered obsolete and deleted based on the defined recovery window, as follows:  
  • Disk: 1-14 days

  • Object Storage: 1-31 days

Creating a Database Backup Policy

Use the Web Console to create a policy to backup a database to the Oracle Fast Recovery Area (FRA) of a disk or to the Object Store.

The backup policy defines the backup, including the location where you want to store the backups and the recovery window. Backup to disk requires a lot of disk space (up to two to three times the size of the database).
  1. Click the Database tab in the Web Console.
  2. Click Backup Policy in the left navigation to display a list of backup policies.
  3. Click Create Backup Policy.
  4. Enter a name for the backup policy and select the number of days for the recovery window. Select Enable Crosscheck to determine if the files on the disk on in the media management catalog correspond to data in the RMAN repository. Select one of the following as the backup destination:
    • To backup to disk, select Disk as the backup destination.
    • To backup to the cloud, select ObjectStore as the backup destination. If you have more than one Object Store, then select the Object Store Credential Name from the list. Enter a name in the Container Name field.
    • To not define a destination, select None.
    The Backup Policy name must begin with an alpha character and contain only alphanumeric characters.

    The following example creates a backup configuration named mkg1dailydiskwith a backup to disk and a 1 day recovery window. Crosscheck is enabled.

  5. Click Create. Click Yes to confirm that you want to create the backup policy.
    A link to the job appears. When the job completes successfully, the backup configuration is ready.
Update an existing database to attach the backup configuration to the database using the ID or Name. When you attach the backup configuration to a database, the dcs-agent schedules daily automatic backups for the database.

Updating a Database Backup Policy

Use the Web Console to update the recovery window or change the crosscheck option for a database backup policy.

Crosscheck determines if the files on the disk on in the media management catalog correspond to data in the RMAN repository.
  1. Click the Database tab in the Web Console.
  2. Click Backup Policy in the left navigation to display a list of backup policies.
  3. Expand the Actions menu for a backup policy, then click Update.
  4. To change the recovery window, use the up or down arrow to change the number of days.
  5. To enable or disable the crosscheck select or deselect Enable Crosscheck.
  6. Click Update. Click Yes to confirm that you want to update the backup policy.
    A link to the job appears. When the job completes successfully, the backup configuration is ready.

Backing Up a Database

Apply a backup policy to a database, create a manual backup, update a database backup schedule, or update an archive log backup.

You can use the Web Console or the command-line interface to create a database backup. In the command-line interface, use the command odacli create-backup for a specified Database Resource ID.
Before creating a database backup, you must have a backup policy. The backup policy defines the recovery window and the backup destination. You can associate a backup policy with the database before creating the backup.
  1. In the Web Console, click the Database tab.
  2. Click a database name to select a database from the list.
  3. Review the database information, including the backup policy name and destination details. To select a backup policy for the database, click Apply Backup Policy. Select a policy.
  4. Click Manual Backup, Update Database Backup Schedule or Update Archive Log Backup.
    If the action is disabled, then apply a backup policy.
  5. Click Yes to confirm the job.
    A link to the job appears. When the job completes successfully, the backup is ready. A list of backups appears at the bottom of the page.

Viewing Backup Logs

Each database has a log of available backups. The log lists the type, location, and date and timestamp of the backup.

  1. In the Web Console, click the Database tab, then click the database name in the list of databases.
    Information about the database appears on the Database Information page.
  2. Scroll to the bottom of the page to view a list of Backups.
  3. Click the Job ID for a backup to view the Backup Report and more details about the backup.

Updating a Database with a Backup Configuration File

Attach a backup configuration file to a database to define the database backup attributes and destination.

  1. In the Web Console, click the Database tab, then select a database from the list.
  2. Expand the Actions menu, then click Update Database with Backup Config.
    If the action is disabled, then you must create a backup configuration file.
  3. Select a backup configuration name from the list of available files, then click Update.
  4. Expand the Actions menu, then click View to display the Database Information page.
    The details include whether or not AutoBackup is disabled, the Backup Config ID number, and options to create a backup and enable or disable automatic backups.
  5. (Optional) Click Create Backup to create a single backup, to enable automatic backups, and to display a list of backups.
  6. (Optional) Click the Database details to display the Backup Config ID, to create a manual backup, or enable automatic backups.
  7. Click the Activitytab to check the job status.
    When the job completes successfully, the backup configuration is associated with the database.

Restoring a Database

Use the Web Console to restore a database from one appliance to another appliance, or to the same appliance when the source database is deleted.

After you backup a database, you can restore it. When you restore a database, environment and validation checks and setup tasks are performed. Restoring a database requires a number of tasks and configuration details, such as creating database storage, Oracle Home, recreating the control file, registering the database, and establishing RMAN restore and recovery. An Oracle Database Appliance backup report is generated for each backup and contains the metadata required to restore a database. The report is designed to help you to quickly and efficiently restore a database.

The following are the prerequisites to restoring a database from a backup:
  1. Obtain Object Store Credentials for the host.

  2. Create a backup policy using the object store credentials as the backup destination.

  3. Attach the backup policy to the database that you want to backup.

  4. Create a manual backup of the database and save the file.

  1. Click the Database tab.
  2. Verify that Auto Refresh Disabled appears on the page.
  3. Click Restore Database from Backup, then click Next to display the Restore Database from Backup page.
  4. Select your Object Store Credential name from the list.
  5. Enter the password in the Backup Encryption Passwords field and the Confirm Backup Encryption Passwords field.
  6. Click Browse and select the backup report.
  7. Click Restore .
    When the backup report is loaded, additional fields appear on the page and are populated based on the backup report.
  8. In the DB Name field, enter a name for the database.
    The name must contain lowercase alphanumeric characters and cannot exceed 8 characters. The Oracle system identifier (SID) is always set to the database name.
  9. Enter the password in the SYS User Password field and the Confirm SYS User Password field.
  10. Click Restore.
  11. Click Yes to confirm that you want to restore the database from the selected Object Store backup.
  12. Validate that the job completed. You can track the job in the Activity tab in the Web Console.

Recovering a Database

Recover the database to the system using a Backup Report, point-in-time recovery (PITR), a system change number (SCN), or from the latest backup time.

Recovering a database in Oracle Database Appliance is a full RMAN database recovery.

Recovering from a backup report requires JSON input for the backup report.

  1. Display a list of backup reports and locate the latest Backup Report for the database and save the Backup Report ID.
    # odacli list-backupreports
    
  2. Use the Backup Report ID to display the details of the Backup Report. Determine how you want to recover the database: PITR, SCN, or Latest and locate the needed information in the Backup Report.
    #  odacli  describe-backupreport -i 2d82460c-d648-4e75-8c7d-72cc90bc442a
    {
      "id" : "2d82460c-d648-4e75-8c7d-72cc90bc442a",
      "dbResId" : "b5fc646e-01a6-4c8b-8286-7633346c4329",
      "tag" : null,
      "dbId" : "2717054291",
      "dbName" : "ExampleDB",
      "dbUniqueName" : "ExampleDBu",
      "backupType" : "REGULAR-L1",
      "keepDays" : null,
      "backupLocation" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket",
      "cfBackupHandle" : "c-2717054291-20180108-04",
      "spfBackupHandle" : "c-2717054291-20180108-04",
      "pitrTimeStamp" : "January 08, 2018 12:43:14 PM UTC",
      "pitrSCN" : "1175058",
      "resetLogsTimeStamp" : "January 08, 2018 09:55:34 AM UTC",
      "resetLogsSCN" : "1112268",
      "oraHomeVersion" : "12.2.0.1.170814 (26723265, 26609817)",
      "sqlPatches" : "25811364,26609817",
      "backupLogLoc" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    rmanlog/ExampleDBu/2717054291/2018-01-08/rman_backup_2018-01-08_12-42-41.0545.log",
      "tdeWalletLoc" : null,
      "dbConfigLoc" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    dbconfig/ExampleDBu/2717054291/2018-01-08/DBCONFIG_TAG20180108T124407_2018-01-08_12-44-07.0533.tar.gz",
      "name" : "Backup_Report_ExampleDB",
      "createTime" : "January 08, 2018 12:42:08 PM UTC",
      "state" : {
        "status" : "CONFIGURED"
      },
      "updatedTime" : "January 08, 2018 12:44:12 PM UTC",
      "backupReportLogDetail" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    rmandetaillogreport/ExampleDBu/2717054291/2018-01-08/rman_list_backup_detail_2018-01-08_12-44-04.0362.log",
      "dbInfo" : {
        "dbClass" : "OLTP",
        "dbType" : "RAC",
        "dbShape" : "odb1",
        "dbEdition" : "EE",
        "dbStorage" : "ASM"
      },
      "dbDataSize" : "1542M",
      "dbRedoSize" : "16403M"
    }
    
  3. To recover from a backup report, based on PITR, identify the database ID and the backup report for recovery.

    In the following example, the JSON input file for the backup report is backupreport.json.

    # odacli recover-database -i b5fc646e-01a6-4c8b-8286-7633346c4 -br backupreport.json -p
    
  4. To recover based on PITR, identify the database ID and the date and time stamp for recovery.
    # odacli recover-database -i b5fc646e-01a6-4c8b-8286-7633346c4 -t PITR -r 01/08/2018 12:57:33 –p
    
  5. To recover based on SCN, identify the database ID and the SCN number.
    # odacli recover-database -i b5fc646e-01a6-4c8b-8286-7633346c4 -t SCN -s 392375947
    
  6. To recover based on the latest backup, identify the database ID and use the Latest option.
    # odacli recover-database -i b5fc646e-01a6-4c8b-8286-7633346c4 -t Latest -p
    
  7. Validate that the job completed. You can track the job in the Activity tab in the Web Console, or run the command odacli describe-job with the job ID.
    # odacli describe-job -ijobId
    
    When the job completes successfully, the recovery is complete.

Deleting Backups

Delete older, obsolete level 0, level 1 and long term backups.

For level 0 and level 1 backups, the recovery window defined in the Backup Configuration determines when the backup is obsolete. The ranges are as follows:

  • Backup to disk: between 1 and 14 days

  • Backup to the Oracle Object Storage: between 1 and 31 days

For Long Term backups to the Oracle Object Storage, view the Backup Report for a database to determine when the backup is obsolete. To delete Long Term Backup, the Database Resource ID or Database name and the Backup Report are required.

  1. Display a list of all backup reports.
    #  odacli  list-backupreports 
    
  2. Obtain the Database ID and type of backup.
    #  odacli  describe-backupreport -i Backup Report ID
    
  3. To delete obsolete level 0 and level 1 backups, use the Database ID to delete the backup.
    # odacli delete-backup -i20576eb1-bc32-4e34-bf97-fda0b60ca15b
    
  4. To delete Long Term backups, use the Backup Report and a JSON file to delete the backup.

    In the following example, the JSON input file for the backup report is backupreport.json.

    # odacli delete-backup -i 20576eb1-bc32-4e34-bf97-fda0b60ca15b -br backupreport.json
    

Deleting a Backup Policy

Use the Web Console to delete a database backup policy.

  1. Click the Database tab in the Web Console.
  2. Click Backup Policy in the left navigation to display a list of backup policies.
  3. Expand the Actions menu for a backup policy, then click Delete. Click Yes to confirm that you want to delete the backup policy.
    A link to the job appears. When the job completes successfully, the backup policy is deleted.

Using the CLI to Backup, Restore, and Recover

Use the command-line interface to create a database backup policy.

Preparing for Database Backup to Disk

Use the command-line interface to create a policy to backup a database to the Oracle Fast Recovery Area (FRA) of a disk.

You can create a backup configuration using the Web Console or the command-line interface. Most of the backup and recovery commands enable you to provide either a resource name or resource ID to identify the database.

Backup to disk requires a lot of disk space (up to two to three times the size of the database).

  1. Create a BackupConfig object (backup configuration) using the command odacli create-backupconfig.
    The backup configuration defines the backup, including the location where you want to store the backups and the recovery window.

    The following example creates a backup configuration named mkg1dailydiskwith a backup to disk and a 1 day recovery window.

    # odacli create-backupconfig -d Disk -n mkg1dailydisk -w 1
    
  2. Check the job status.
    # odacli list-jobs
    
    When the job completes successfully, the backup configuration is ready.
  3. (Optional) Update an existing database to attach the backup configuration to the database using the ID or Name.
    When you attach the backup configuration to a database, the dcs-agent schedules daily automatic backups for the database.

    The following example uses the Database Resource ID and Backup Configuration ID:

    #  odacli  update-database  -i d3c4d8f6-5eb7-4f9e-ab27-7bdd5013ac90 -bi 9d942e0a-ba00-4cbc-9bfb-0de83ed279e5 -bp 
    

    The following example uses the Database Resource Name, mydb and the Backup Configuration Name, mydb:

    # odacli update-database -in mydb -bin mybcfg -bp
    
You can create manual backups or scheduled backups to disk.

Preparing for Database Backup to Oracle Cloud

Create a backup configuration to backup a database to Oracle Cloud Infrastructure Object Storage.

Before you can backup to Oracle Object Storage, you must sign up for an Oracle Cloud Infrastructure Object Storage account and know your Oracle Object Storage credentials. When you create an Oracle ObjectStoreSwift object, the command creates and stores the credential details in the system and stores the password in an encrypted Oracle wallet. The Oracle wallet contains your tenant name, user name, and defines the end point URL.

Go to the Oracle Store to sign up for Oracle Cloud Infrastructure Object Storage.

  1. Create an Oracle ObjectStoreSwift object using the command create-objectstoreswift. If you already have an Oracle wallet for Oracle Database Appliance, skip to Step 2.
    # odacli  create-objectstoreswift -e swift end point URL -n Object Store Swift name [-p] swiftpassword -t Object Store tenant name -u Object Store user name
    

    For example:

    # odacli create-objectstoreswift -e https://swiftobjectstorage.r1.oracleiaas.com/v1 -n ossn1 -t mytenant -u user.name@example.com -p
    
    The output includes an objectstoreswift Resource ID to identify an ObjectStoreSwift credential.
  2. Create a BackupConfig object (backup configuration) using the command odacli create-backupconfig .
    The backup configuration defines the backup, including the location (container) where you want to store the backups, the recovery window, and the credentials that are defined in your encrypted Oracle wallet.

    The following example creates a backup configuration named hr_7d_cloudwith a backup to the ObjectStore. The following backup parameters are defined: the container is hr_bucket, crosscheck is not enabled, the recovery window is 7 days, and the ObjectStoreSwift Resource ID is provided, which attaches the Oracle Wallet and credentials to the backup configuration.

     # odacli  create-backupconfig  -n hr_7d_cloud -d ObjectStore -w 7 -o b974f006-5503-4949-ab6c-6f1a56e4ac37 -c hr_bucket -no-cr  
    

    Note:

    If the ObjectstoreSwift Object was not created with valid credentials, then creating the backup configuration will fail.
  3. Check the job status.
    # odacli list-jobs
    
    When the job completes successfully, the backup configuration is ready. When you create a new database, you have the option to associate the database with a backup configuration.
  4. (Optional) Update an existing database to attach the backup configuration to the database.
    When you attach the backup configuration to a database, the dcs-agent schedules daily automatic backups for the database.
    #  odacli  update-database  -i e3c4d8f6-5eb7-4f9e-ab27-7bdd5013ac10 -bi 7d942e0a-ba00-4cbc-9bfb-0de83ed279e5 -bp 
    
You can create manual backups outside of scheduled backups, view backup reports, or disable automatic backups.

Backing Up a Database with the CLI

Create a level 0, level 1, or LongTerm database backup with the command-line interface.

You can create a database backup in the Web Console or with the command-line interface. When you attach a backup configuration file to a database, the dcs-agent automatically schedules daily backups for the database. The day and time are based on the Oracle Database Appliance time zone. The AutoSchedule triggers a level 0 Backup every Sunday and a level 1 the other 6 days of the week. Use the command odacli update-schedule to disable or change the scheduled backup time.

To create a Long Term database backup, or a level 0 or level 1 backup outside of the automatic backups, use the command odacli create-backup.

Note:

To recover a database, you can use disk or Oracle Object Storage and a level 0 backup report. To restore a database to another system, you must have a Long Term database backup in Oracle Object Storage.
  1. Verify that a backup configuration file is associated with the database.
  2. Create a single backup, outside of the automatic backups, by using the command odacli create-backup.
    Use the Database Resource ID to identify the database to backup, specify the type of backup, and use a tag to create a name for the backup. You can use up to 30 alphanumeric characters for the backup name tag. If you do not select a backup type (level 0, level 1, or LongTerm), a level 1 backup is performed. For example, create a level 0 backup named 2018Jan02_HRLevel0 for resource ID 20576eb1-bc32-4e34-bf97-fda0b60ca15b
    # odacli  create-backup -i20576eb1-bc32-4e34-bf97-fda0b60ca15b -bt Regular-L0 -t 2018Jan02_HRLevel0
    
    When the job finishes, a backup report is generated for the backup. The report contains all of the metadata required to recover a database.
  3. (Optional) Display a list of backup reports.
    #  odacli  list-backupreports 
    
  4. (Optional) Display a list of all scheduled backups.
    # odacli list-schedules
    

Restoring a Database with the CLI

Restore a database to a system from Oracle Object Storage using a Backup Report and the command-line interface.

When you restore a database, environment and validation checks and setup tasks are performed. Restoring a database requires a number of tasks and configuration details, such as creating database storage, Oracle Home, recreating the control file, registering the database, and establishing RMAN restore and recovery. An Oracle Database Appliance backup report is generated for each backup and contains the metadata required to restore a database. The report is designed to help you to quickly and efficiently restore a database.

You can restore a database from one appliance to another appliance, or to the same appliance when the source database is deleted:

  • To restore to a different system, copy the backup report generated by the command odacli create-backup to the other machine's \bin folder and use the command odacli irestore-database with the backup report.

  • To restore to the same system, delete the source database and use the backup report generated by the command odacli create-backup.

To restore a database to another system, you must have a database backup report in Oracle Object Storage, valid credentials in an Oracle wallet (ObjectStoreSwift), the Swift Object Store credential ID, and the SYS user password.
  1. Display a list of backup reports and locate the latest Backup Report in Oracle Object Storage for the database and save the Backup Report ID.
    # odacli list-backupreports
    
  2. Use the Backup Report ID to display the details of the Backup Report.
    #  odacli  describe-backupreport -i 2d82460c-d648-4e75-8c7d-72cc90bc442a
    {
      "id" : "2d82460c-d648-4e75-8c7d-72cc90bc442a",
      "dbResId" : "b5fc646e-01a6-4c8b-8286-7633346c4329",
      "tag" : null,
      "dbId" : "2717054291",
      "dbName" : "ExampleDB",
      "dbUniqueName" : "ExampleDBu",
      "backupType" : "REGULAR-L1",
      "keepDays" : null,
      "backupLocation" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket",
      "cfBackupHandle" : "c-2717054291-20180108-04",
      "spfBackupHandle" : "c-2717054291-20180108-04",
      "pitrTimeStamp" : "January 08, 2018 12:43:14 PM UTC",
      "pitrSCN" : "1175058",
      "resetLogsTimeStamp" : "January 08, 2018 09:55:34 AM UTC",
      "resetLogsSCN" : "1112268",
      "oraHomeVersion" : "12.2.0.1.170814 (26723265, 26609817)",
      "sqlPatches" : "25811364,26609817",
      "backupLogLoc" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    rmanlog/ExampleDBu/2717054291/2018-01-08/rman_backup_2018-01-08_12-42-41.0545.log",
      "tdeWalletLoc" : null,
      "dbConfigLoc" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    dbconfig/ExampleDBu/2717054291/2018-01-08/DBCONFIG_TAG20180108T124407_2018-01-08_12-44-07.0533.tar.gz",
      "name" : "Backup_Report_ExampleDB",
      "createTime" : "January 08, 2018 12:42:08 PM UTC",
      "state" : {
        "status" : "CONFIGURED"
      },
      "updatedTime" : "January 08, 2018 12:44:12 PM UTC",
      "backupReportLogDetail" : "https://swiftobjectstorage.example.com/v1/dbaasimage/backupbucket/system_namec1n1/
    rmandetaillogreport/ExampleDBu/2717054291/2018-01-08/rman_list_backup_detail_2018-01-08_12-44-04.0362.log",
      "dbInfo" : {
        "dbClass" : "OLTP",
        "dbType" : "RAC",
        "dbShape" : "odb1",
        "dbEdition" : "EE",
        "dbStorage" : "ASM"
      },
      "dbDataSize" : "1542M",
      "dbRedoSize" : "16403M"
    }
    
  3. (Optional) If you need to generate a new backup report, use the command odacli create-backup.
    # odacli create-backup
    
  4. Locate the Swift Object Store credential ID for the database backup.
    # odacli list-objectstoreswifts 
    
  5. Save the backup report as a JSON file in a folder in the \bin directory on the appliance. For example, backupreport.json.
  6. Restore the database to the system using the JSON file in the command odacli irestore-database.
    Run the command, then enter the SYS user password when prompted.
    # odacli irestore-database -r backupreport.json -oid Object Store ID -m
    
  7. Validate that the job completed. You can track the job in the Activity tab in the Web Console, or run the command odacli describe-job with the job ID.
    # odacli describe-job -ijobId