May 21, 2021|5 min|Developers

Neo Oracle Workflow — Now in Ansible!

Automate Oracle Database Protection with Cohesity’s Ansible Module

When it comes to relational database management systems, Oracle is one of the undeniable leaders in the business, and it’s also one of the most relied upon systems in the enterprise.

Oracle application owners and database admins face tough challenges when it comes to protecting a large number of databases. Data volumes are continuously expanding due to growth in database sizes, as well as regulatory compliance policies requiring increasingly extended data-retention periods.

Cohesity can help enterprise organizations overcome the challenges of data protection and recovery strategies for their Oracle database infrastructures. Among its many enterprise features and capabilities, Cohesity’s data platform includes an integrated data protection solution. Cohesity’s solution provides end-to-end data protection that can replace traditional backup and recovery solutions and simplify data center operations.

Cohesity’s platform is based on an API-driven architecture that focuses on automation, consumable APIs, and self-service capabilities from the get-go. Users can enjoy error-free consistency and self-service manageability that extends the capabilities of individual applications and enables IT to spend less time with management and more time with ambitious, value-oriented projects.

Continue reading to learn how you can leverage the Cohesity Ansible Module to automate the protection workflow for Oracle databases.

Register Oracle Database

The register workflow involves installing the Cohesity agent on the server where Oracle DB is hosted. If you use the Cohesity Ansible module to do so, you can deploy agents on multiple machines. See the agent-install sample playbooks, including playbooks to install agents on Windows and on Linux servers. Check out this sample inventory file that will be used to install agents on the Oracle servers:

[localhost]
127.0.0.1 ansible_connection=local

[oracle]
10.2.146.241
10.2.146.240

[oracle:vars]
ansible_user=adam
ansible_password=asdf
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
var_cohesity_server=orcl-db1.web.prod.com

[all:vars]
var_cohesity_server=cohesity_cluster_password
var_cohesity_username=cohesity_cluster_username
var_cohesity_password=cohesity_cluster_password
var_validate_certs=cohesity_certs

The next step is to register the physical server with Cohesity as a server and then register it as an Oracle application. These are two separate steps when performed in the UI, but if you use the Cohesity Ansible module, the two steps are combined into one. See this sample playbook for registering an Oracle DB.

# => Register Oracle protection sources
---
  - hosts: localhost
    gather_facts: no
    become: False
    roles:
      - cohesity.cohesity_ansible_role
    tasks:
      # => Cycle through each member of the hosts and register as Cohesity Protection Source
      - name: Create new Protection Source as Oracle source.
        include_role:
            name: cohesity.cohesity_ansible_role
            tasks_from: oracle_source
        vars:
            cohesity_server: "{{ var_cohesity_server }}"
            cohesity_admin: "{{ var_cohesity_username }}"
            cohesity_password: "{{ var_cohesity_password }}"
            cohesity_validate_certs: "{{ var_validate_certs }}"
            cohesity_oracle:
                state: present
                force_register: True
                endpoint: "{{ item }}"
                db_username: "{{ db_username }}"
                db_password: "{{ db_password }}"
        with_items: "{{ groups['oracle'] }}"

Unregister Oracle Database

The playbook to unregister the Oracle DB is similar to the register playbook. The difference is the state must be set to absent and there is no need to pass the credentials for the DB.


state: absent

Create Cohesity Protection Group

Once your Oracle DB is registered with Cohesity, you can start protecting it by creating a Protection Group. See the create_oracle_job.yml sample playbook to create a Protection Group. You need to specify the Storage Domain, Protection Policy and other information, as shown in this code snippet:


#=> Create a Oracle protection job for Oracle sources available in the vCenter
---
  - hosts: localhost
    gather_facts: no
    roles:
      - cohesity.cohesity_ansible_role
    tasks:
      - name: Protection job
        include_role:
          name: cohesity.cohesity_ansible_role
          tasks_from: oracle_job
        vars:
          cohesity_server:  "{{ var_cohesity_server }}"
          cohesity_admin: "{{ var_cohesity_username }}"
          cohesity_password: "{{ cohesity_cluster_password }}"
          cohesity_validate_certs: "{{ var_validate_certs }}"
          cohesity_oracle:
              state: present
              job_name: protect_Oracle
              storage_domain: "DefaultStorageDomain"
              policy: "Silver"
              endpoint: "orcl-db1.web.prod.co"
              cancel_active: true

You can also specify individual DBs within your Oracle DB to be protected on Cohesity:

cohesity_oracle:
               state: present
               job_name: protect_Oracle
               storage_domain: "DefaultStorageDomain"
               policy: "Silver"
               endpoint: "{{ item }}"
               cancel_active: true
               environment: Oracle
               databases:
                 - "dbs01"
                 - "dbs02"
               time_zone: America/LosAngeles
       with_items: "{{ groups['oracle'] }}"

Delete Protection Group

Deleting the Protection Group is also similar to the above playbook. The difference here is that you need to set the state to absent.

cohesity_oracle:
               state: absent
               job_name: protect_Oracle
               storage_domain: "DefaultStorageDomain"
               policy: "Silver"
               endpoint: "{{ item }}"
               cancel_active: true
               environment: Oracle
               databases:
                 - "dbs01"
               time_zone: America/LosAngeles
       with_items: "{{ groups['oracle'] }}"

Restore Oracle Database

There are two restore workflows for Oracle DBs. You can either restore the Oracle DB to the original or alternate server or clone the Oracle DB to a Cohesity View. Both these workflows are possible using the Cohesity Ansible module.

See the restore.yml sample file, where you need to pass a couple of Oracle DB parameters to create a recovery task and perform the Oracle DB recovery. Note that you need to pass the target Oracle server, which can be the same as the source server.

#=> Create a new Oracle database restore.
---
  - hosts: localhost
    gather_facts: no
    roles:
      - cohesity.cohesity_ansible_role
    tasks:
      - name: Restore Oracle Job
        include_role:
          name: cohesity.cohesity_ansible_role
          tasks_from: oracle_restore
        vars:
           cohesity_server: "{{ var_cohesity_server }}"
           cohesity_admin: "{{ var_cohesity_username }}"
           cohesity_password: "{{ var_cohesity_password }}"
           cohesity_validate_certs: "{{ var_validate_certs }}"
           cohesity_oracle:
               source_db: cdb1
               task_name: recover_tasks
               source_server: {{ source_server }}
               target_server: {{ target_server }}
               target_db: cdb1
               oracle_home: /u01/app/Oracle/product/12.1.0.2/db_1
               oracle_base: /u01/app/Oracle
               oracle_data: /u01/app/Oracle/product/12.1.0.2/db_1
               log_time: null
               overwrite: true
               no_recovery: false

To clone the Oracle DB to a Cohesity View, see the restore-clone.yml sample playbook.


#=> Create an Oracle database restore(clone) to Cohesity view.
---
  - hosts: localhost
    gather_facts: no
    roles:
      - cohesity.cohesity_ansible_role
    tasks:
      - name: Restore Oracle Job
        include_role:
          name: cohesity.cohesity_ansible_role
          tasks_from: oracle_restore
        vars:
          cohesity_server: "{{ var_cohesity_server }}"
          cohesity_admin: "{{ var_cohesity_username }}"
          cohesity_password: "{{ var_cohesity_password }}"
          cohesity_validate_certs: "{{ var_validate_certs }}"
          cohesity_oracle:
              source_db: cdb1
              task_name: recover_tasks
              source_server: {{ source_server }}

Wrap Up

We saw how we can automate the end-to-end Oracle protection workflow (Register, Protect, and Recover) using Cohesity’s integration with Ansible. We also have many more samples and workflows that are supported — find out more on the Cohesity Ansible Role Github page. To learn more about Cohesity’s other Ansible integrations, make sure to visit our Ansible Landing page on the Cohesity Developer Portal.

As always, suggestions are welcome and if you want to see a new workflow using Ansible, reach out to the Cohesity API team and we will make it happen!

Written by

chandrashekar-dashudi-headshot

Chandrashekar Dashudu

Technical Marketing Engineer

chandrashekar-dashudi-headshot

Chandrashekar Dashudu

Technical Marketing Engineer

Chandrashekar is a TME who serves as an SME for Cohesity's API and API integration. Apart for API, he focuses on Cohesity Marketplace apps. He is an engineering background in Computer Science from NCSU.

X image
Icon ionic ios-globe

You are now leaving the German section of www.cohesity.com/de/ and come to an English section of the site. Please click if you want to continue.

Don't show this warning again

Icon ionic ios-globe

You are now leaving the German section of www.cohesity.com/de/ and come to an English section of the site. Please click if you want to continue.

Don't show this warning again