Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code snippet for restoring Jira index files from snapshot
---
- name: Wait for index files folder ready
wait_for:
path: "{{ atl_product_home }}/caches/indexesV1"
delay: 60
sleep: 10
timeout: 120
ignore_errors: yes
- name: Find the latest Jira index snapshot from backup
shell:
cmd: "ls -t {{ atl_product_home_shared }}/export/indexsnapshots/IndexSnapshot* | head -n1"
register: latest_jira_index_snapshot
- name: Stop jira service
service:
name: jira.service
state: stopped
- name: Recursively remove Jira index files directory
file:
path: "{{ atl_product_home }}/caches/indexesV1"
state: absent
- name: Create Jira index files directory
file:
path: "{{ atl_product_home }}/caches/indexesV1"
state: directory
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
- name: Restore Jira index from latest backup snapshot (.zip)
unarchive:
src: "{{ latest_jira_index_snapshot.stdout }}"
dest: "{{ atl_product_home }}/caches/indexesV1"
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
when: "'.zip' in latest_jira_index_snapshot.stdout"
ignore_errors: yes
- name: Restore Jira index from latest backup snapshot (.tar.sz)
shell:
cmd: "/usr/local/bin/snzip -c -d {{ latest_jira_index_snapshot.stdout }} | tar xvf - -C {{ atl_product_home }}/caches/indexesV1"
become: yes
become_user: "{{ atl_product_user }}"
when: "'.tar.sz' in latest_jira_index_snapshot.stdout"
ignore_errors: yes
- name: Find the latest Zephyr index snapshot from backup
shell:
cmd: "ls -t {{ atl_product_home_shared }}/zfj/index_backup/IndexSnapshot* | head -n1"
register: latest_zephyr_index_snapshot
- name: Create Zephyr index files directory
file:
path: "{{ atl_product_home }}/caches/indexesV1/plugins/JEEntity/schedule"
state: directory
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
mode: 0755
- name: Restore Zephyr index from latest backup snapshot (.zip)
unarchive:
src: "{{ latest_zephyr_index_snapshot.stdout }}"
dest: "{{ atl_product_home }}/caches/indexesV1/plugins/JEEntity/schedule"
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
when: "'.zip' in latest_zephyr_index_snapshot.stdout"
ignore_errors: yes
- name: Start jira service
service:
name: jira.service
state: started
- name: Check if jira is ready to serve traffics
uri:
url: http://localhost:8080/status
method: GET
use_proxy: no
register: jira_response
until: jira_response.status == 200
retries: 60
delay: 10
- name: Stop jira service
service:
name: jira.service
state: stopped
- name: Start jira service
service:
name: jira.service
state: started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment