Skip to content

Commit 47c80b8

Browse files
author
Marcin Przepiorowski
committed
adding scripts
1 parent bbd67fd commit 47c80b8

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

scripts/backup_dlpx_metadata.sh

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#!/bin/bash
2+
3+
######################################################################################
4+
##### Backup of Delphix Engine metadata include only metadata related to objects #####
5+
###### and not Delphix Engine configuration itself. Dxtoolkit can backup users, ######
6+
###### polices, templates and operation templates and can generate a scripts to ######
7+
############ recreate other objects like environments, dSources and VDB’s ############
8+
######################################################################################
9+
############ Passwords are not exported and are set to default values like ###########
10+
################## xxxxxxxx for Delphix users #########################
11+
################## xxxxxxxx for Environment users #########################
12+
################## xxxxxxxx for Database users #########################
13+
################## xxxxxxxx for OracleMT root DB user (c##user) ####################
14+
######################################################################################
15+
16+
##############
17+
# Author: Jatinder Luthra
18+
# Pre-req: dxtoolkit
19+
##############
20+
21+
engine_name=$1
22+
23+
## Validating argument is passed ##
24+
25+
if [[ $# -eq 0 ]]; then
26+
echo ""
27+
echo "!!!! Error:: Pass Delphix Engine Name as in dxtools.conf file !!!!"
28+
echo ""
29+
exit 0
30+
fi
31+
32+
###### change below variable values as per your environment #######
33+
34+
dxtoolkit_dir="/Users/jatinder.luthra/Desktop/Customers/BOA/dxtoolkit2"
35+
36+
backup_path="/Users/jatinder.luthra/Desktop/Scripts/DR_Scripts/DR_backups"
37+
38+
default_os_pwd="welcome123"
39+
40+
default_db_pwd="welcome123"
41+
42+
####### no changes required below this point ##########
43+
44+
backup_date=$(date '+%m%d%Y-%H%M%S')
45+
46+
backup_dir="${backup_path}/${engine_name}-metadata-backup-${backup_date}"
47+
48+
49+
echo ""
50+
echo "####################################################################################################"
51+
echo "############## Metadata Backup of engine, ${engine_name} started under directory, ${backup_dir} ####"
52+
echo "####################################################################################################"
53+
echo ""
54+
55+
###### create backup directory ######
56+
57+
echo "###### Creating backup directory, ${backup_dir} ######"
58+
59+
mkdir ${backup_dir}
60+
61+
##### Checking Engine Status #######
62+
63+
echo ""
64+
echo "######### Checking Delphix Engine Status #########"
65+
66+
chk_status=`${dxtoolkit_dir}/dx_get_appliance -d ${engine_name}`
67+
echo $chk_status > ${backup_dir}/status.txt
68+
69+
if [[ ${chk_status} =~ "Can't check session status" || ${chk_status} =~ "Can't find" ]]; then
70+
echo "Either Delphix Engine, ${engine_name} is not up OR ${engine_name} entry not present in conf file"
71+
exit 0
72+
else
73+
echo "Delphix Engine ${engine_name} is acessible. Proceeding with metadata backup"
74+
fi
75+
76+
###### Backup Engine Configuration #######
77+
78+
echo ""
79+
echo "######### Backing up Delphix Engine Configuration #########"
80+
81+
engine_sys_name=${engine_name}_sys
82+
sys_config_dir=${backup_dir}/sys_config
83+
mkdir ${sys_config_dir}
84+
sys_config_file=sys_config.csv
85+
appliance_info=appliance_info.csv
86+
latency_info=network_latency.csv
87+
throughput_info=network_throughput.csv
88+
hierarchy_info=hierarchy_info.txt
89+
90+
echo "Backup exported into ${sys_config_dir}"
91+
92+
${dxtoolkit_dir}/dx_get_config -d ${engine_sys_name} -format csv > ${sys_config_dir}/${sys_config_file}
93+
94+
${dxtoolkit_dir}/dx_get_appliance -d ${engine_name} -details -format csv > ${sys_config_dir}/${appliance_info}
95+
96+
${dxtoolkit_dir}/dx_get_network_tests -d ${engine_name} -type latency -format csv > ${sys_config_dir}/${latency_info}
97+
98+
${dxtoolkit_dir}/dx_get_network_tests -d ${engine_name} -type throughput -format csv > ${sys_config_dir}/${throughput_info}
99+
100+
###### Backup Users and Profiles #######
101+
102+
echo ""
103+
echo "######### Backing up Delphix Engine Users and Profiles #########"
104+
105+
users_file=users.csv
106+
profiles_file=profile.csv
107+
users_dir=${backup_dir}/users
108+
mkdir ${users_dir}
109+
110+
echo "Backup exported into ${users_dir}"
111+
112+
${dxtoolkit_dir}/dx_get_users -d ${engine_name} -export ${users_dir}/${users_file} -profile ${users_dir}/${profiles_file}
113+
114+
###### Backup Engine policies #######
115+
116+
echo ""
117+
echo "######### Backing up Delphix Engine Policies #########"
118+
119+
policy_file=policy.mapping
120+
policy_dir=${backup_dir}/policies
121+
mkdir ${policy_dir}
122+
123+
${dxtoolkit_dir}/dx_get_policy -d ${engine_name} -export -outdir ${policy_dir} -mapping ${policy_dir}/${policy_file}
124+
125+
###### Backup Config templates ######
126+
127+
echo ""
128+
echo "######### Backing up Config Templates #########"
129+
130+
131+
template_dir=${backup_dir}/config_templates
132+
mkdir ${template_dir}
133+
134+
${dxtoolkit_dir}/dx_get_template -d ${engine_name} -export -outdir ${template_dir}
135+
136+
###### Backup hooks ######
137+
138+
echo ""
139+
echo "######### Backing up Operation Templates (Hooks) #########"
140+
141+
142+
hooks_dir=${backup_dir}/hook_templates
143+
mkdir ${hooks_dir}
144+
145+
${dxtoolkit_dir}/dx_get_op_template -d ${engine_name} -exportHook -outdir ${hooks_dir}
146+
147+
###### Generate environment creation scripts ######
148+
149+
echo ""
150+
echo "######### Backing up environments metadata #########"
151+
152+
env_dir=${backup_dir}/environments
153+
mkdir ${env_dir}
154+
155+
${dxtoolkit_dir}/dx_get_env -d ${engine_name} -backup ${env_dir}
156+
157+
#### add executable at start of each line #####
158+
#### Update the correct passwords for OS users ####
159+
160+
sed "s/^/.\//; s/xxxxxxxx/${default_os_pwd}/g" ${env_dir}/backup_env.txt > ${env_dir}/backup_env.sh
161+
162+
###### Generate dSource and VDB creation scripts ######
163+
164+
echo ""
165+
echo "######### Backing up dSource and VDB metadata #########"
166+
167+
db_dir=${backup_dir}/db_objects
168+
mkdir ${db_dir}
169+
170+
${dxtoolkit_dir}/dx_get_db_env -d ${engine_name} -backup ${db_dir}
171+
172+
#### add executable at start of each line #####
173+
174+
sed "s/^/.\//; s/xxxxxxxx/${default_db_pwd}/g" ${db_dir}/backup_metadata_dsource.txt > ${db_dir}/backup_metadata_dsource.sh
175+
176+
sed "s/^/.\//" ${db_dir}/backup_metadata_vdb.txt > ${db_dir}/backup_metadata_vdb.sh
177+
178+
echo ""
179+
echo "######### Backing up Self Service metadata #########"
180+
181+
ss_dir=${backup_dir}/ss_objects
182+
mkdir ${ss_dir}
183+
184+
echo "Backup exported into ${ss_dir}"
185+
186+
${dxtoolkit_dir}/dx_get_js_templates -d ${engine_name} -backup ${ss_dir}
187+
188+
${dxtoolkit_dir}/dx_get_js_containers -d ${engine_name} -backup ${ss_dir}
189+
190+
#### add executable at start of each line #####
191+
192+
sed "s/^/.\//" ${ss_dir}/backup_selfservice_templates.txt > ${ss_dir}/backup_selfservice_templates.sh
193+
194+
sed "s/^/.\//" ${ss_dir}/backup_selfservice_containers.txt > ${ss_dir}/backup_selfservice_containers.sh
195+
196+
### Adding execute permissions to backup directory ###
197+
198+
chmod -R 770 ${backup_dir}
199+
200+
201+
echo ""
202+
echo "####################################################################################################"
203+
echo "############## Metadata Backup of engine, ${engine_name} finished under directory ############"
204+
echo "## Check backup files under directory, ${backup_dir} ##"
205+
echo "####################################################################################################"
206+
echo ""
207+
exit 0

0 commit comments

Comments
 (0)