Skip to content

Commit 648662a

Browse files
Merge pull request #79 from ashviniwaghmode/feature/backup_restore_api_based_python_code
Feature/backup restore api based python code
2 parents 7cace45 + df3aa18 commit 648662a

File tree

7 files changed

+948
-0
lines changed

7 files changed

+948
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# NetBackup VMware agentless single and group VM backup and restore APIs code samples
2+
3+
## Executing the scripts:
4+
5+
Pre-requisites:
6+
- NetBackup 8.3 or higher
7+
- Python 3.6 or higher
8+
- Python modules: `requests`
9+
- create_protection_plan_template.json template file. This template contain the required payload which is used to create the protection plan.
10+
11+
Use the following commands to run the scripts.
12+
### - Single VM backup and restore
13+
14+
This single_vm_backup_restore.py script demonstrates how to backup a VM (VMware virtual machine) using a protection plan and instant access restore of VM using NetBackup APIs.
15+
16+
`python single_vm_backup_restore.py --master_server <master_server> --master_username <master_username> --master_password <master_password> --vcenter_name <vcenter_name> --vcenter_username <vcenter_username> --vcenter_password <vcenter_password> --stu_name <stu_name> --protection_plan_name <protection_plan_name> --clientvm <client_vm_name> --restore_vmname <restore_vm_name>`
17+
18+
All parameters can also be passed as command line arguments.
19+
- `python single_vm_backup_restore.py --help`
20+
```
21+
usage: single_vm_backup_restore.py [-h] [--master_server MASTER_SERVER]
22+
[--master_server_port MASTER_SERVER_PORT]
23+
[--master_username MASTER_USERNAME]
24+
[--master_password MASTER_PASSWORD]
25+
[--vcenter_name VCENTER_NAME]
26+
[--vcenter_username VCENTER_USERNAME]
27+
[--vcenter_password VCENTER_PASSWORD]
28+
[--vcenter_port VCENTER_PORT]
29+
[--stu_name STU_NAME]
30+
[--protection_plan_name PROTECTION_PLAN_NAME]
31+
[--clientvm CLIENTVM]
32+
[--restore_vmname RESTORE_VMNAME]
33+
34+
Single VM backup and restore scenario
35+
36+
Arguments:
37+
-h, --help show this help message and exit
38+
--master_server MASTER_SERVER
39+
NetBackup master server name
40+
--master_server_port MASTER_SERVER_PORT
41+
NetBackup master server port
42+
--master_username MASTER_USERNAME
43+
NetBackup master server username
44+
--master_password MASTER_PASSWORD
45+
NetBackup master server password
46+
--vcenter_name VCENTER_NAME
47+
vCenter name
48+
--vcenter_username VCENTER_USERNAME
49+
vCenter username
50+
--vcenter_password VCENTER_PASSWORD
51+
vCenter password
52+
--vcenter_port VCENTER_PORT
53+
vCenter port
54+
--stu_name STU_NAME
55+
Storage unit name
56+
--protection_plan_name PROTECTION_PLAN_NAME
57+
Protection plan name
58+
--clientvm CLIENTVM Client VM name
59+
--restore_vmname RESTORE_VMNAME
60+
Restore VM name
61+
```
62+
63+
Execution flow of single VM backup and restore script:
64+
- Add vcenter to NBU master
65+
- Discovery of Vcenter
66+
- Create protection plan
67+
- Subscribe asset to protection plan
68+
- Perform immediate backup
69+
- Verify the status of jobs
70+
- Initiate instant access recovery
71+
- Verify state of instant access recovery VM.
72+
- Perform the cleanup(e.g. remove instant access VM, subscription, protection plan and vcenter)
73+
74+
### - Group VM backup and restore
75+
76+
This group_vm_backup_restore.py script demonstrates how to backup multiple VMs (VMware virtual machines) using a protection plan and perform bulk instant access restore of the VMs using NetBackup APIs.
77+
78+
`python group_vm_backup_restore.py --master_server <master_server> --master_username <master_username> --master_password <master_password> --vcenter_name <vcenter_name> --vcenter_username <vcenter_username> --vcenter_password <vcenter_password> --stu_name <stu_name> --protection_plan_name <protection_plan_name> --querystring <Query_string> --vip_group_name <group_name> --restore_vmname_prefix <restore_vmname_prefix>`
79+
80+
All parameters can also be passed as command line arguments.
81+
- `python group_vm_backup_restore.py --help`
82+
```
83+
usage: group_vm_backup_restore.py [-h] [--master_server MASTER_SERVER]
84+
[--master_server_port MASTER_SERVER_PORT]
85+
[--master_username MASTER_USERNAME]
86+
[--master_password MASTER_PASSWORD]
87+
[--vcenter_name VCENTER_NAME]
88+
[--vcenter_username VCENTER_USERNAME]
89+
[--vcenter_password VCENTER_PASSWORD]
90+
[--vcenter_port VCENTER_PORT]
91+
[--stu_name STU_NAME]
92+
[--protection_plan_name PROTECTION_PLAN_NAME]
93+
[--querystring QUERYSTRING]
94+
[--vip_group_name VIP_GROUP_NAME]
95+
[--restore_vmname_prefix RESTORE_VMNAME_PREFIX]
96+
97+
Group VM backup and restore scenario
98+
99+
Arguments:
100+
-h, --help show this help message and exit
101+
--master_server MASTER_SERVER
102+
NetBackup master server
103+
--master_server_port MASTER_SERVER_PORT
104+
NetBackup port
105+
--master_username MASTER_USERNAME
106+
NetBackup master server user name
107+
--master_password MASTER_PASSWORD
108+
NetBackup master server password
109+
--vcenter_name VCENTER_NAME
110+
Vcenter name
111+
--vcenter_username VCENTER_USERNAME
112+
Vcenter username
113+
--vcenter_password VCENTER_PASSWORD
114+
Vcenter password
115+
--vcenter_port VCENTER_PORT
116+
Vcenter port
117+
--stu_name STU_NAME
118+
Storage unit name
119+
--protection_plan_name PROTECTION_PLAN_NAME
120+
Protection plan name
121+
--querystring QUERYSTRING
122+
Query string to create the VM intelligent group
123+
--vip_group_name VIP_GROUP_NAME
124+
VM intelligent group name
125+
--restore_vmname_prefix RESTORE_VMNAME_PREFIX
126+
Restore VM name prefix
127+
```
128+
Execution flow of group VM backup and restore script:
129+
- Add vcenter to NBU master
130+
- Discovery of Vcenter
131+
- Create protection plan
132+
- Create intelligent VM group based on the querystring
133+
- Subscribe VM group to protection plan
134+
- Perform immediate backup
135+
- Verify the status of jobs
136+
- Perform bulk restore
137+
- Perform the cleanup(e.g. remove bulk instant access VMs, subscription, protection plan, VM group and vcenter)

0 commit comments

Comments
 (0)