-
Notifications
You must be signed in to change notification settings - Fork 11
/
backup_and_restore.yaml
130 lines (120 loc) · 3.64 KB
/
backup_and_restore.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
- name: Commvault Ansible
gather_facts: no
hosts: localhost
connection: local
vars:
webconsole_hostname: 'hostname'
commcell_username: 'username'
commcell_password: 'password'
client: 'sample client'
tasks:
- name: Commvault commcell initialization
block:
- name: Login
commvault:
operation: LOGIN
entity: {
webconsole_hostname: "{{ webconsole_hostname }}",
commcell_username: "{{ commcell_username }}",
commcell_password: "{{ commcell_password }}"
}
register: commcell
- debug:
msg: "Login is done successfully"
rescue:
- debug:
msg: 'Login failed'
- name: Backup
block:
- name: performing backup
commvault:
operation: "backup"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "file system",
backupset: "defaultbackupset",
subclient: "default"
}
register: backup_job
- debug:
msg: "Successfully started backup job: {{ backup_job.output }}"
- name: wait for backup job to complete
commvault:
operation: "wait_for_completion"
entity_type: "job"
commcell: "{{ commcell }}"
entity: {
job_id: "{{ backup_job.output }}"
}
register: backup_status
- name: Backup job failure reason
when: backup_status.output == false
commvault:
operation: "delay_reason"
entity_type: "job"
commcell: "{{ commcell }}"
entity: {
job_id: "{{ backup_job.output }}"
}
register: failure_reason
- debug:
msg: "{{ failure_reason.output }}"
when: backup_status.output == false
ignore_errors: yes
- debug:
msg: "Backup job completed successfully"
when: backup_status.output == true
ignore_errors: yes
rescue:
- debug:
msg: 'Backup failed'
- name: Restore
when: backup_status.output == true
commvault:
operation: "restore_in_place"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "file system",
backupset: "defaultbackupset",
subclient: "default"
}
args: {
paths: ['C:\testing']
}
register: restore_job
- debug:
msg: "Successfully started Restore job: {{ restore_job.output }}"
- name: wait for restore job to complete
when: restore_job is succeeded
commvault:
operation: "wait_for_completion"
entity_type: "job"
commcell: "{{ commcell }}"
entity: {
job_id: "{{ restore_job.output }}"
}
register: restore_status
- name: Backup job failure reason
when: restore_status.output == false
commvault:
operation: "delay_reason"
entity_type: "job"
commcell: "{{ commcell }}"
entity: {
job_id: "{{ restore_job.output }}"
}
register: failure_reason
- debug:
msg: "{{ failure_reason.output }}"
when: restore_status.output == false
ignore_errors: yes
- debug:
msg: "{{ Restore job completed successfully }}"
when: restore_status.output == true
ignore_errors: yes
...