-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
94 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
- name: "Execute a one shot backup of Squest" | ||
hosts: localhost | ||
gather_facts: true | ||
|
||
tasks: | ||
- name: Generate job name | ||
ansible.builtin.set_fact: | ||
job_name: backup-{{ ansible_date_time.date }} | ||
|
||
- name: Create Job from backup cronjob | ||
shell: "kubectl --namespace {{ squest_namespace }} create job --from=cronjob/squest-backup {{ job_name }}" | ||
environment: | ||
KUBECONFIG: "{{ k8s_kubeconfig_path }}" | ||
register: register_backup | ||
failed_when: | ||
- register_backup.rc != 0 | ||
- '"already exists" not in register_backup.stdout' | ||
|
||
- name: Wait until backup complete | ||
kubernetes.core.k8s_info: | ||
kubeconfig: "{{ k8s_kubeconfig_path }}" | ||
api_version: "batch/v1" | ||
kind: Job | ||
name: "{{ job_name }}" | ||
namespace: "{{ squest_namespace }}" | ||
wait: yes | ||
wait_sleep: 10 | ||
wait_timeout: 120 | ||
wait_condition: | ||
type: Complete | ||
status: "True" | ||
|
||
- when: squest_django.externalize_backup_via_rsync.enabled | ||
block: | ||
- name: Generate job name | ||
ansible.builtin.set_fact: | ||
job_name: rsync-backup-{{ ansible_date_time.date }} | ||
|
||
- name: Create Job from rsync backup cronjob | ||
shell: "kubectl --namespace {{ squest_namespace }} create job --from=cronjob/squest-rsync-backup {{ job_name }}" | ||
environment: | ||
KUBECONFIG: "{{ k8s_kubeconfig_path }}" | ||
register: register_backup | ||
failed_when: | ||
- register_backup.rc != 0 | ||
- '"already exists" not in register_backup.stdout' | ||
|
||
- name: Wait until rsync backup complete | ||
kubernetes.core.k8s_info: | ||
kubeconfig: "{{ k8s_kubeconfig_path }}" | ||
api_version: "batch/v1" | ||
kind: Job | ||
name: "{{ job_name }}" | ||
namespace: "{{ squest_namespace }}" | ||
wait: yes | ||
wait_sleep: 10 | ||
wait_timeout: 120 | ||
wait_condition: | ||
type: Complete | ||
status: "True" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters