Skip to content

Commit

Permalink
Merge pull request #665 from ministryofjustice/oasys_db_refresh_2
Browse files Browse the repository at this point in the history
Corrected spool file name same as db name
  • Loading branch information
KarenMoss1510 authored Apr 5, 2024
2 parents 050561a + 12c4c1a commit e221cab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Check if ORACLE_DB_REFRESH_DB_NAME is defined
- name: Check if SOURCE_DB is defined
fail:
msg: "ORACLE_DB_REFRESH_DB_NAME is not defined"
when: ORACLE_DB_REFRESH_DB_NAME == ""
msg: "SOURCE_DB is not defined"
when: SOURCE_DB == ""

- name: Install SQL Script
template:
Expand All @@ -24,8 +24,8 @@
- name: Copy the latest backup control file handle details to the runner
fetch:
src: /tmp/{{ ORACLE_DB_REFRESH_FILE }}
dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ ORACLE_DB_REFRESH_FILE }}"
src: "/tmp/{{ SOURCE_DB }}_control.txt"
dest: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ SOURCE_DB }}_control.txt"
flat: yes
fail_on_missing: yes

Expand All @@ -34,5 +34,5 @@
path: "{{ item }}"
state: absent
loop:
- "/tmp/{{ SOURCE_DB }}_control.txt"
- "/tmp/get_latest_backup_control_file.sql"
- "/tmp/{{ ORACLE_DB_REFRESH_FILE }}"
7 changes: 6 additions & 1 deletion ansible/roles/oracle-db-refresh/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
- import_tasks: get_latest_backup_control_file.yml
tags:
- oracle_db_refresh
- oracle_db_refresh_get_latest_backup_control_file
- get_latest_backup_control_file

- import_tasks: oracle_db_restore.yml
tags:
- oracle_db_refresh
- refresh_db
17 changes: 17 additions & 0 deletions ansible/roles/oracle-db-refresh/tasks/oracle_db_restore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Check if TARGET_DB is defined
fail:
msg: "TARGET_DB is not defined"
when: TARGET_DB == ""

- name: Check if SOURCE_DB is defined
fail:
msg: "SOURCE_DB is not defined"
when: SOURCE_DB == ""

- name: Copy the latest backup control file handle details to the runner
fetch:
src: "{{ lookup('env','GITHUB_WORKSPACE') | default('/tmp', true) }}/{{ SOURCE_DB }}_control.txt"
dest: "/tmp/{{ TARGET_DB }}_control.txt"
flat: yes
fail_on_missing: yes
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set head off echo off feedback off
spool /tmp/{{ ORACLE_DB_REFRESH_FILE }}
spool /tmp/{{ SOURCE_DB }}_control.txt
with controlfile_details as
(
select db_key, max(stamp) stamp from rcvcatowner.rc_backup_controlfile
where autobackup_date is NULL and db_name = '{{ ORACLE_DB_REFRESH_DB_NAME }}'
where autobackup_date is NULL and db_name = '{{ SOURCE_DB }}'
group by db_key
)
select a.HANDLE from rcvcatowner.rc_backup_piece a, controlfile_details b, rcvcatowner.rc_backup_controlfile c
Expand Down
3 changes: 0 additions & 3 deletions ansible/roles/oracle-db-refresh/vars/main.yml

This file was deleted.

0 comments on commit e221cab

Please sign in to comment.