Skip to content

Instantly share code, notes, and snippets.

@jc1518
Last active October 29, 2020 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jc1518/1fb4298397abd64bb87eb1d82003d610 to your computer and use it in GitHub Desktop.
Save jc1518/1fb4298397abd64bb87eb1d82003d610 to your computer and use it in GitHub Desktop.
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