-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsap_maxdb_syscopy.sh
1923 lines (1799 loc) · 74.3 KB
/
sap_maxdb_syscopy.sh
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/bash
# SYSCOPY MaxDB AIX/LINUX ###############################################################################
################################################################################ (c) 2022 Florian Lamml #
# Prerequisites #########################################################################################
# - copy this script to the source host and set the execution right #
# - ssh communication between source and target without password (authorized_keys) for both sidadm #
# via "ssh-keygen -t rsa -b 2048" and ".ssh/authorized_keys" (only source --> target) #
# --> ssh sourceadm@sourcehost must work without PW #
# --> ssh targetadm@targethost must work without PW #
# - the target database is large enough (automatic check) #
# - xuser DEFAULT for ABAP/JAVA DB User (SAP<SID> or SAP<SID>DB) must be available #
# - if passwords from source and target are different, xuser for copy can not be used #
# - the source database must be online, the target database must be able to start in state admin #
# - adjust the configuration of source and target system in this script #
# - best use with screen tool for unix/linux #
# - under Linux it can happen that you have to change the first line #
# from "#!/usr/bin/bash" to "#!/bin/bash" (check bash with "which bash") #
#########################################################################################################
# Features ##############################################################################################
# - automatic function and prerequisites check #
# - backup to 2 parallel PIPE #
# - can use compressed and uncompressed backup (default uncompress) #
# - root is not needed #
# - copy status bar with size, transfered, left and speed (5 second update) #
# - automatic size check #
# - dd over ssh from source to target #
# - ssh encryption default cipher is aes192-ctr #
# - automatic rename database to target #
# - automatic export of custom tables (incl. templates of the most common) #
# - you can use a custom db user or xuser for backup and restore #
#########################################################################################################
# Exit Codes ############################################################################################
# exit 0 = normal or user exit #
# exit 99 = script run as root #
# exit 98 = another script is running #
# exit 97 = source database is not available #
# exit 96 = source database size bigger than target database max size #
# exit 95 = error in backup start #
# exit 94 = error in restore start #
# exit 93 = error in backup #
# exit 92 = error in restore #
# exit 91 = error with SSH on source #
# exit 90 = error with SSH on target #
# exit 89 = error with temporary status files on source #
# exit 88 = error with temporary status files on target #
# exit 87 = error with pipes on source #
# exit 86 = error with pipes on target #
# exit 85 = error in config check #
# exit 84 = error in target db start #
# exit 83 = error in target backup template create #
# exit 82 = error in source backup template create #
# exit 81 = error in rename target db #
#########################################################################################################
# Configuration start ###################################################################################
# configuration need to be adjusted
#
# source host (example: server1 or the IP)
export sourcehost=server1
#
# target host (example: server2 or the IP)
export targethost=server2
#
# source SID (example: AAA)
export sourcesid=AAA
#
# target SID (example: BBB)
export targetsid=BBB
#
# logfile name (example/default: DB_Copy_AAAtoBBB_01011900.log)
export dbcopylog=DB_Copy_"$sourcesid"to"$targetsid"_$(date "+%d%m%Y").log
#
# send mail after syscopy (default no)
export sendfinishmail=no
export mailadress=user@domain.tld
#
#
#### Export / Import Options ####
# save sec directory with the sap certificates (default yes, saved in cdD/cdJ as syscopy_sec)
export savesecdir=yes
# define if abap or java (default abap)
export abaporjava=abap
#custom table export and imports (default is only e070l and sap license, yes or no)
# Export location on target (default /tmp, without ending / -> /tmp = OK, /tmp/ = NOT OK)
export exportlocation=/tmp
# import after syscopy (default yes)
export autoimport=yes
# export/import client (default 000, only all or 000, DO NOT USE ANY OTHER CLIENT)
export expimpclient=000
# export E070L (default yes, should be done if target is an existing system)
export e07lexport=yes
# SAP License (default yes)
export licexport=yes
# RZ10 Profiles
export rz10export=no
# RZ04 Operation Modes
export rz04export=no
# STRUST
export strustexport=no
# STRUSTSSO2
export strustsso2export=no
# STMS_QA (manual refresh in SAP needed before you can start)
export stmsqaexport=no
# STMS configuration
export stmsexport=no
# AL11
export al11export=no
# BD54
export bd54export=no
# FILE
export fileexport=no
# RZ70/SLD configuration
export rz70sldexport=no
# SCOT
export scotexport=no
# SICF services
export sicfexport=no
# RFC connections
export rfcconnectionsexport=no
# SM69 external commands
export sm69export=no
# WE20 WE21 BD97
export we202197export=no
# SMLG/RZ12
export smlgrz12export=no
# ABAP Dev (only if target is a development system)
export abapdevexport=no
# GTS/SLL Export
export gtssllexport=no
# OAC0
export oac0export=no
# SCC4
export scc4export=no
# Report Variants
export reportvariants=no
# DBACOCKPIT
export dbacockpit=no
# HTTPURLLOC
export httpurlloc=no
# LDAP
export ldap=no
# VSCAN
export vscan=no
# SPAD
export spad=no
# EWZ5
export ewz5=no
# SBGRFCCONF
export sbgrfcconf=no
# SBWP
export sbwp=no
# SECPOL
export secpol=no
# SECSTORE
export secstore=no
# SM19
export sm19=no
# Custom Tables (adjust array tables_customtables like this ('table1' 'table2' 'table3') if / in Table name -> ''\''/TABPART/TABPART'\')
export customtables=no
declare -a tables_customtables=('table1' 'table2' 'table3')
#
#### Expert Options ####
# change only if you know exactly what you are doing #
#
# use xuser instead of normal db user (default yes)
# Info: If you use xuser, no passwords will shown at the console
# Info: use 'xuser list' to show the available xusers
# WARNING: CAN NOT BE USED IF TARGET AND SOURCE DB USERS HAVE DIFFERENT PASSWORDS!
# WARNING: If the passwords of the target and source db users are different you have to set no!
export usexuser=yes
#
# xuserkey source (default w, xusersource need at least Backup, DBInfoRead, AccessUtility and SystemCmd)
export xusersource=w
#
# xuserkey target (default w, xusertarget need at least DBStart, DBStop, DBInfoRead, AccessUtility, SystemCmd, AccessSQL, LoadSysTab and Recovery)
export xusertarget=w
#
# source db user for backup (default SUPERDBA, need at least Backup, DBInfoRead, AccessUtility and SystemCmd)
# Warning: If you use db users, passwords will shown at the console
# only used if usexuser=no
export dbsourceuser=SUPERDBA
#
# target db user for restore (default SUPERDBA, need at least DBStart, DBStop, DBInfoRead, AccessUtility, SystemCmd, AccessSQL, LoadSysTab and Recovery)
# Warning: If you use db users, passwords will shown at the console
# only used if usexuser=no
export dbtargetuser=SUPERDBA
#
# second clear log run (default is no, yes or no)
export secondclearlog=no
#
# compressed backup (default is no, yes or no)
# Warning: can adversely affect the performance of the source system!
export backupcompressed=no
#
# ssh cipher (default aes192-ctr, example: arcfour, arcfour128, arcfour256, aes192-ctr, aes256-ctr, aes192-cbc, aes256-cbc etc.)
# on IBM Power7 "arcfour" is the fastest, on IBM Power8 "aes192-ctr" is best of security and speed
export sshcipher=aes192-ctr
#
# MaxDB pipe size (default 128 (1MB), value in pages and 1 page = 8 KB)
# dd blocksize and MaxDB pipe size are interdependent!
# pipesize should half blocksize (blocksize in k / 8 / 2)
# Warning: can adversely affect the performance of the source system!
# low performance impact but lower speed --> 8-32
# high performance impact but faster --> >= 64
export pipesize=128
#
# dd blocksize (default is automatic calculated, example: 8k, 512k, 1M, 16M)
# dd blocksize and MaxDB pipe size are interdependent!
# blocksize should be double pipesize (pipesize * 8 * 2 k)
# Warning: can adversely affect the performance of the source system!
export blocksize=$(echo "($pipesize*8*2)" | bc -l)k
# export blocksize=2048k
#
# disable CTRL+C on some points to prevent damage and endless processes (default yes)
export disablectrlc=yes
#
# remove export file after successfull import (default no)
export remexpafterimp=no
#
# enable batch mode (no security question, default no)
# INFO: to run in batchmode you have to use nohup (example "nohup db_copy_xx.sh &")
# INFO: batchmode is only possible if you use xuser!
export enablebatch=no
#
#
#### Transport and SQL configuration ####
# change only if you know exactly what you are doing #
#
# sql tables to delete
declare -a sql_deltables=('ALCONSEG' 'ALSYSTEMS' 'DBSNP' 'MONI' 'OSMON' 'PAHI' 'SDBAD' 'SDBAH' 'SDBAP' 'SDBAR' 'DDLOG' 'TPFET' 'TPFHT' 'TLOCK' 'CNHIST' 'CNREPRT' 'CNMEDIA' 'DBSTATHADA' 'DBSTATIHADA' 'DBSTATIADA' 'DBSTATTADA' 'SDBAADAUPD')
# e07lexport
declare -a tables_e07lexport=('E070L')
# licexport
declare -a tables_licexport=('SAPLIKEY')
# rz10export
declare -a tables_rz10export=('TPFET' 'TPFHT')
# rz04export
declare -a tables_rz04export=('BTCOMSET' 'TPFBA' 'TPFID')
# strustexport
declare -a tables_strustexport=('SMIME_CAPA_CRYPT' 'SMIME_CAPA_SIGN' 'SMIME_CAPABILITY' 'SSF_PSE_D' 'SSF_PSE_H' 'SSF_PSE_HIST' 'SSF_PSE_L' 'SSF_PSE_T' 'SSFAPPLIC' 'SSFAPPLICT' 'SSFARGS' 'SSFVARGS' 'SSFVARGST' 'SSFVKEYDEF' 'STRUSTCAB' 'STRUSTCABEMAIL' 'STRUSTCERT' 'STRUSTCRL' 'STRUSTCRP' 'STRUSTCRPT' 'STRUSTCRR' 'STRUSTCRRT' 'STRUSTCRS' 'STRUSTCRT' 'STRUSTSMIM' 'STRUSTSMIMT' 'STRUSTSSL' 'STRUSTSSLS' 'STRUSTSSLST' 'STRUSTSSLT' 'STRUSTWSSE' 'STRUSTWSSET' 'TWPSSO2ACL' 'USERINFO_STORAGE' 'USRCERTMAP' 'USRCERTRULE')
# strustsso2export
declare -a tables_strustsso2export=('SNCSYSACL' 'TSP0U' 'TXCOMSECU' 'USRACL' 'USRACLEXT')
# stmsqaexport
declare -a tables_stmsqaexport=('TMSQNOTES' 'TMSQNOTESH' 'TMSQWLF' 'TMSQWLFH' 'TMSQWLH' 'TMSQWLN' 'TMSQWL' 'TMSQLASTWL')
# stmsexport
declare -a tables_stmsexport=('ALMBCDATA' 'DLV_SYSTC' 'E070L' 'E070USE' 'TCECLILY' 'TCECPSTAT' 'TCEDELI' 'TCERELE' 'TCESYST' 'TCESYSTT' 'TCETARG' 'TCETARGHDR' 'TCETARGT' 'TCETRAL' 'TCETRALT' 'TCEVERS' 'TCEVERST' 'TMSACTDAT' 'TMSALOG' 'TMSALOGAR' 'TMSALRTSYS' 'TMSBCIBOX' 'TMSBCIIBOX' 'TMSBCIJOY' 'TMSBCINEX' 'TMSBCINTAB' 'TMSBCIOBJ' 'TMSBCIXBOX' 'TMSBUFCNT' 'TMSBUFPRO' 'TMSBUFREQ' 'TMSBUFTXT' 'TMSCDES' 'TMSCDOM' 'TMSCDOMT' 'TMSCNFS' 'TMSCNFST' 'TMSCROUTE' 'TMSCSYS' 'TMSCSYST' 'TMSCTOK' 'TMSFSYSH' 'TMSFSYSL' 'TMSMCONF' 'TMSPCONF' 'TMSPVERS' 'TMSQASTEPS' 'TMSQASTEPT' 'TMSQASTEPZ' 'TMSQCONFRM' 'TMSSRV' 'TMSSRVT' 'TMSTLOCKNP' 'TMSTLOCKNR' 'TMSTLOCKP' 'TMSTLOCKR' 'TRBAT' 'TRJOB' 'TRNSPACE' 'TRNSPACEL' 'TRNSPACETT')
# al11export
declare -a tables_al11export=('USER_DIR')
# bd54export
declare -a tables_bd54export=('TBDLS' 'TBDLST')
# fileexport
declare -a tables_fileexport=('FILENAME' 'FILENAMECI' 'FILEPATH' 'FILESYS' 'FILETEXT' 'FILETEXTCI' 'FSYSTXT' 'OPSYSTEM' 'OPTEXT' 'PARAMVALUE' 'PATH' 'PATHTEXT' 'USER_DIR')
# rz70sldexport
declare -a tables_rz70sldexport=('LCRT_INDX' 'SLDAGADM')
# scotexport
declare -a tables_scotexport=('BCSD_BLMODULE' 'BCSD_BREAKLOOP' 'BCSD_RQST' 'BCSD_STML' 'SXADMINTAB' 'SXCONVERT' 'SXCONVERT2' 'SXCOS' 'SXCOS_T' 'SXCPDEF' 'SXCPRECV' 'SXCPSEND' 'SXDEVTYPE' 'SXDEVTYPL' 'SXDOMAINS' 'SXJOBS' 'SXNODES' 'SXPARAMS' 'SXRETRY' 'SXROUTE' 'SXSERV' 'SXTELMOIN' 'SXTELMOOUT' 'T005J' 'T005K' 'TSAPD')
# sicfexport
declare -a tables_sicfexport=('ICF_SESSION_CNTL' 'ICFALIAS' 'ICFAPPLCUST' 'ICFAPPLICATION' 'ICFDOCU' 'ICFHANDLER' 'ICFINSTACT' 'ICFSECPASSWD' 'ICFSERVICE' 'ICFSERVLOC' 'ICFVIRHOST' 'TWPURLSVR')
# rfcconnectionsexport
declare -a tables_rfcconnectionsexport=('APC_CROSS_ORIGIN' 'RFC_TT_ACL' 'RFC_TT_ACL_HIST' 'RFC_TT_SAMEU' 'RFCADPTATTR' 'RFCATTRIB' 'RFCCAT' 'RFCCBWHITELIST' 'RFCCBWHITELIST_A' 'RFCCHECK' 'RFCCMC' 'RFCDES' 'RFCDESSECU' 'RFCDOC' 'RFCGO' 'RFC2SOAPS' 'RFCSOAPS' 'RFCSYSACL' 'RFCSYSACL_CLNT' 'RFCTRUST' 'RFCTXTAB' 'RFCSTXTAB' 'RFCTYPE' 'RSECACHK' 'RSECACTB' 'RSECKEYMETA' 'RSECTAB' 'SNCSYSACL')
# we202197export
declare -a tables_we202197export=('EDIPO' 'EDIPO2' 'EDIPOA' 'EDIPOACODPAG' 'EDIPOD' 'EDIPOF' 'EDIPOI' 'EDIPORT' 'EDIPOX' 'EDIPOXH' 'EDIPOXU' 'EDP12' 'EDP13' 'EDP21' 'EDPP1' 'TBLSYSDEST' 'TBSPECDEST')
# sm69export
declare -a tables_sm69export=('SXPGCOSTAB')
# smlgrz12export
declare -a tables_smlgrz12export=('RZLLICLASS' 'RZLLITAB')
# abapdevexport
declare -a tables_abapdevexport=('ADIRACCESS' 'DEVACCESS' 'ENHCONTRACTCONT' 'ENHLOG' 'ENHOBJCONTRACT' 'RSEUMOD' 'VRSD' 'VRSMODISRC' 'VRSX' 'VRSX2' 'VRSX3' 'VRSX4' 'VRSX5')
# gtssllexport
declare -a tables_gtssllexport=(''\''/SAPSLL/TCOGVA'\' ''\''/SAPSLL/TCOGVS'\' ''\''/SAPSLL/TCOGVST'\')
# oac0export
declare -a tables_oac0export=('TOAAR')
# scc4export
declare -a tables_scc4export=('T000' 'CLMS_TENANT')
# reportvariants
declare -a tables_reportvariants=('TVARVC' 'VARI' 'VARID' 'VARIDESC' 'VARINUM' 'VARIS' 'VARIT')
# dbacockpit
declare -a tables_dbacockpit=('DB6NAVSYST' 'DB6PMPROT' 'DBA_CONFIG' 'DBCON' 'DBCONUSR' 'SDBAD' 'SDBAH' 'SDBAP' 'SDBAR')
# httpurlloc
declare -a tables_httpurlloc=('HTTPURLLOC' 'IACORDES' 'IACORDEST' 'IACORSITE')
# ldap
declare -a tables_ldap=('LDAPGATEW' 'LDAPMAP1' 'LDAPMAP2' 'LDAPMAP3' 'LDAPMAP4' 'LDAPMAP5' 'LDAPMAP6' 'LDAPSERVER' 'LDAPSYNC' 'LDAPUSER')
# vscan
declare -a tables_vscan=('VSCAN_GROUP' 'VSCAN_GROUP_P' 'VSCAN_GROUPT' 'VSCAN_PROF' 'VSCAN_PROF_GRP' 'VSCAN_PROF_PAR' 'VSCAN_PROFT' 'VSCAN_SERVER')
# SPAD
declare -a tables_spad=('TSP03' 'TSP03A' 'TSP03C' 'TSP03D' 'TSP03L' 'TSP03POCCNF' 'TSP03POCPRE' 'TSP03T' 'TSP0B' 'TSP0K' 'TSPCMDS' 'TSPLOMS' 'TSPROMS' 'TSPSV')
# EWZ5
declare -a tables_ewz5=('EWUUSERTYP')
# SBGRFCCONF
declare -a tables_sbgrfcconf=('BGRFC_CUST_I_DST' 'BGRFC_CUST_I_SRV' 'BGRFC_CUST_I_SYS' 'BGRFC_CUST_O_DST' 'BGRFC_CUST_O_SRV' 'BGRFC_CUST_O_SYS' 'BGRFC_CUST_SUPER' 'BGRFC_MAIN_I_DST' 'QRFC_CUST_I_DEST')
# SBWP
declare -a tables_sbwp=('SODM' 'SOFD' 'SOFM' 'SOID' 'SOOD' 'SOUB' 'SOUC' 'SOUD')
# SECPOL
declare -a tables_secpol=('SEC_POLICY_CUST' 'SEC_POLICY_CUSTT' 'SEC_POLICY_RT')
# SECSTORE
declare -a tables_secstore=('RSECACTB' 'RSECTAB' 'RSECTAB')
# SM19
declare -a tables_sm19=('RSAU_BUF_DATA' 'RSAU_TEMP_CDATA' 'RSAU_TEMP_DATA' 'RSAUFILES' 'RSAUFILES_STAT' 'RSAUPROF' 'RSAUPROFEX')
# Configuration end #####################################################################################
# INFOS AND CHECKS ######################################################################################
# variables - do NOT modify
export targetsidadm=$(echo $targetsid | tr '[:upper:]' '[:lower:]')adm
export sourcesidadm=$(echo $sourcesid | tr '[:upper:]' '[:lower:]')adm
export pipedate=$(date "+%d%m%Y")
export workdirectory=$(pwd)
export dbcopy_script_version='GitHub Version 1.3.1 (c) Florian Lamml - 2022'
# clear screen
clear
### define functions ###
# mail batch check
function sendmailcheckbatch {
if [ $sendfinishmail == yes ] && [ $enablebatch == yes ];
then
echo $RCCODE | mail -s "System Copy $sourcesid to $targetsid ERROR in checks" "$mailadress"
fi
}
# function batchmode ssh source
function batchmodesshsource {
ssh -oBatchMode=yes -oForwardX11=no -c $sshcipher $sourcesidadm@$sourcehost "$1"
}
# function batchmode ssh target
function batchmodesshtarget {
ssh -oBatchMode=yes -oForwardX11=no -c $sshcipher $targetsidadm@$targethost "$1"
}
# function ssh source
function sshsource {
ssh -oForwardX11=no -c $sshcipher $sourcesidadm@$sourcehost "$1"
}
# function ssh target
function sshtarget {
ssh -oForwardX11=no -c $sshcipher $targetsidadm@$targethost "$1"
}
# sleep and space
function sleepandspace {
sleep 1
echo "=====" | tee -a $dbcopylog
sleep 1
}
# send mail normal
function sendmailnormal {
if [ $sendfinishmail == yes ];
then
cat $dbcopylog | mail -s "System Copy $sourcesid to $targetsid finish" "$mailadress"
fi
}
# send mail batch
function sendmailbatch {
if [ $sendfinishmail == yes ] && [ $enablebatch == yes ];
then
cat $dbcopylog | mail -s "System Copy $sourcesid to $targetsid ERROR" "$mailadress"
fi
}
### define functions ###
# do some checks
echo "===================================="
echo "DB Copy Script "$(date "+%d.%m.%Y %H:%M:%S")
echo $dbcopy_script_version
echo "===================================="
echo "Check environment, please wait..."
# root check
echo -ne "* Check root... \c"
if [ "$(whoami)" == "root" ];
then
echo "This script must not be run as root user! ... EXIT! (RC=99)"
export RCCODE="This script must not be run as root user! ... EXIT! (RC=99)"
sendmailcheckbatch
exit 99
fi
sleep 1
echo "OK!"
# test source login an cipher
echo -ne "* Check SSH on source... \c"
batchmodesshsource 'exit'
if [ $? -ne 0 ];
then
echo "Problem with SSH on source! .ssh/authorized_keys OK? SSH Cipher OK? known hosts OK? ... EXIT! (RC=91)"
export RCCODE="Problem with SSH on source! .ssh/authorized_keys OK? SSH Cipher OK? known hosts OK? ... EXIT! (RC=91)"
sendmailcheckbatch
exit 91
fi
sleep 1
echo "OK!"
# test target login an cipher
echo -ne "* Check SSH on target... \c"
batchmodesshtarget 'exit'
if [ $? -ne 0 ];
then
echo "Problem with SSH on target! .ssh/authorized_keys OK? SSH Cipher OK? known hosts OK? ... EXIT! (RC=90)"
export RCCODE="Problem with SSH on target! .ssh/authorized_keys OK? SSH Cipher OK? known hosts OK? ... EXIT! (RC=90)"
sendmailcheckbatch
exit 90
fi
sleep 1
echo "OK!"
# lock file
echo -ne "* Check lockfile... \c"
export copylockfile=/tmp/dbcopy.lock
if [ -f $copylockfile ];
then
kill -0 $(cat $copylockfile) &>/dev/null
if [ $? -eq 0 ];
then
echo "Another copy script is still running. ... EXIT! (RC=98)"
export RCCODE="Another copy script is still running. ... EXIT! (RC=98)"
sendmailcheckbatch
exit 98
else
echo -ne "Deprecated lock file found. Remove lock file. \c"
rm -f $copylockfile
fi
fi
sleep 1
echo "OK!"
# write lockfile
echo $$ > $copylockfile
# logfile check
echo -ne "* Check logfile... \c"
if [ -f $dbcopylog ];
then
echo -ne "Logfile with same name exists - rename to "$dbcopylog"."$(date "+%d%m%Y%H%M%S")"... \c"
mv $dbcopylog $dbcopylog.$(date "+%d%m%Y%H%M%S")
fi
sleep 1
echo "OK!"
# check config
echo -ne "* Check config... \c"
if [ $enablebatch == yes ] && [ $usexuser == no ];
then
echo "Cannot run batchmode without xusers, check your config... EXIT! (RC=85)"
export RCCODE="Cannot run batchmode without xusers, check your config... EXIT! (RC=85)"
sendmailcheckbatch
exit 85
elif [ -z "$sourcehost" ] || [ -z "$targethost" ] || [ -z "$sourcesid" ] || [ -z "$targetsid" ] || [ -z "$dbcopylog" ] || [ -z "$pipesize" ] || [ -z "$blocksize" ] || [ -z "$exportlocation" ];
then
echo "Some parameter missing... EXIT! (RC=85)"
export RCCODE="Some parameter missing... EXIT! (RC=85)"
sendmailcheckbatch
exit 85
fi
sleep 1
echo "OK!"
# check temporary status files source
echo -ne "* Check tempfile write on source... \c"
export check_tmprcheck=0
declare -a check_tempstatusfiles=('/tmp/dbcopy_tmpbacklist' '/tmp/dbcopy_backuplog' '/tmp/dbcopy_backupend' '/tmp/dbcopy_tmp_recover_state' '/tmp/dbcopy_pipecopyend_1' '/tmp/dbcopy_pipecopyend_2' '/tmp/dbcopy_deltables.sql' '/tmp/dbcopy_tmp_exporttables.tpl' '/tmp/dbcopy_tmp_exporttables_unsort.tpl' '/tmp/dbcopy_tmp_exporttables_sort.tpl' '/tmp/dbcopy_dbsizetarget_'$sourcesid'' '/tmp/dbcopy_dbversion_'$sourcesid'')
for check_tempstatusfile in "${check_tempstatusfiles[@]}"
do
touch $check_tempstatusfile &>/dev/null
export check_tmprcheck=$(($check_tmprcheck + $?))
done
if [ $check_tmprcheck -ne 0 ];
then
echo "Problem to create temporary status files on source. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=89)"
rm -f $copylockfile
export RCCODE="Problem to create temporary status files on source. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=89)"
sendmailcheckbatch
exit 89
fi
for check_tempstatusfile in "${check_tempstatusfiles[@]}"
do
rm $check_tempstatusfile
done
sleep 1
echo "OK!"
# check temporary status files target
echo -ne "* Check tempfile write on target... \c"
export check_tmprcheck=0
declare -a check_tempstatusfiles=('/tmp/dbcopy_tmprestlist' '/tmp/dbcopy_restorelog' '/tmp/dbcopy_restoreend' '/tmp/dbcopy_deltables.sql' '/tmp/dbcopy_dbsizetarget_'$targetsid'' '/tmp/dbcopy_dbversion_'$targetsid'' ''$exportlocation'/'$targetsid'_dbcopy_exporttables.tpl' ''$exportlocation'/'$targetsid'_dbcopy_exporttables.log' '/tmp/dbcopy_renamedbsid' '/tmp/dbcopy_dbonline' '/tmp/dbcopy_changesqlpass')
for check_tempstatusfile in "${check_tempstatusfiles[@]}"
do
batchmodesshtarget 'touch '$check_tempstatusfile'' &>/dev/null
export check_tmprcheck=$(($check_tmprcheck + $?))
done
if [ $check_tmprcheck -ne 0 ];
then
echo "Problem to create temporary status files on target. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=88)"
rm -f $copylockfile
export RCCODE="Problem to create temporary status files on target. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=88)"
sendmailcheckbatch
exit 88
fi
for check_tempstatusfile in "${check_tempstatusfiles[@]}"
do
batchmodesshtarget 'rm '$check_tempstatusfile''
done
sleep 1
echo "OK!"
# check pipes on source
echo -ne "* Check pipes on source... \c"
export check_tmprcheck=0
touch /tmp/"$sourcesid"to"$targetsid"_pipe_t_"$pipedate"_1 &>/dev/null
export tmprcheck=$(($tmprcheck + $?))
touch /tmp/"$sourcesid"to"$targetsid"_pipe_t_"$pipedate"_2 &>/dev/null
export tmprcheck=$(($tmprcheck + $?))
if [ $check_tmprcheck -ne 0 ];
then
echo "Problem to create pipes on source. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=87)"
rm -f $copylockfile
export RCCODE="Problem to create pipes on source. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=87)"
sendmailcheckbatch
exit 87
fi
rm /tmp/"$sourcesid"to"$targetsid"_pipe_t_"$pipedate"_1
rm /tmp/"$sourcesid"to"$targetsid"_pipe_t_"$pipedate"_2
sleep 1
echo "OK!"
# check pipes on target
echo -ne "* Check pipes on target... \c"
export check_tmprcheck=0
batchmodesshtarget 'touch /tmp/'$sourcesid'to'$targetsid'_pipe_t_'$pipedate'_1' &>/dev/null
export tmprcheck=$(($tmprcheck + $?))
batchmodesshtarget 'touch /tmp/'$sourcesid'to'$targetsid'_pipe_t_'$pipedate'_2' &>/dev/null
export tmprcheck=$(($tmprcheck + $?))
if [ $check_tmprcheck -ne 0 ];
then
echo "Problem to create pipes on target. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=86)"
rm -f $copylockfile
export RCCODE="Problem to create pipes on target. Check if there are in /tmp old data from a previous run! ... EXIT! (RC=86)"
sendmailcheckbatch
exit 86
fi
batchmodesshtarget 'rm /tmp/'$sourcesid'to'$targetsid'_pipe_t_'$pipedate'_1'
batchmodesshtarget 'rm /tmp/'$sourcesid'to'$targetsid'_pipe_t_'$pipedate'_2'
sleep 1
echo "OK!"
#info
echo "===================================="
sleep 2
# clear screen
clear
# message
echo "====================================" | tee -a $dbcopylog
echo "DB Copy Script "$(date "+%d.%m.%Y %H:%M:%S") | tee -a $dbcopylog
echo $dbcopy_script_version | tee -a $dbcopylog
echo "====================================" | tee -a $dbcopylog
echo "Source DB.........:" $sourcesid | tee -a $dbcopylog
echo "Source HOST.......:" $sourcehost | tee -a $dbcopylog
echo "Source SAPADM.....:" $sourcesidadm | tee -a $dbcopylog
if [ $usexuser == yes ];
then
echo "Source XUSER Key..:" $xusersource | tee -a $dbcopylog
else
echo "Source DB User....:" $dbsourceuser | tee -a $dbcopylog
fi
echo "Target DB.........:" $targetsid | tee -a $dbcopylog
echo "Target HOST.......:" $targethost | tee -a $dbcopylog
echo "Target SAPADM.....:" $targetsidadm | tee -a $dbcopylog
if [ $usexuser == yes ];
then
echo "Target XUSER Key..:" $xusertarget | tee -a $dbcopylog
else
echo "Target DB User....:" $dbtargetuser | tee -a $dbcopylog
fi
if [ $sourcehost == $targethost ];
then
echo "Local System Copy.: yes" | tee -a $dbcopylog
fi
echo "DB Copy Logfile...:" $dbcopylog | tee -a $dbcopylog
echo "Compressed Backup.:" $backupcompressed | tee -a $dbcopylog
echo "SSH Cipher.......:" $sshcipher | tee -a $dbcopylog
echo "DD Blocksize......:" $blocksize | tee -a $dbcopylog
echo "MaxDB PIPE Size...:" $pipesize | tee -a $dbcopylog
echo "Save secdir.......:" $savesecdir | tee -a $dbcopylog
echo "Table Export......: yes/no" | tee -a $dbcopylog
echo "Table E/I Client..:" $expimpclient | tee -a $dbcopylog
echo "* SAP License.....:" $licexport | tee -a $dbcopylog
echo "* E070L...........:" $e07lexport | tee -a $dbcopylog
echo "* RZ10 Profiles...:" $rz10export | tee -a $dbcopylog
echo "* RZ04 Modes......:" $rz04export | tee -a $dbcopylog
echo "* STRUST..........:" $strustexport | tee -a $dbcopylog
echo "* STRUSTSSO2......:" $strustsso2export | tee -a $dbcopylog
echo "* STMS_QA.........:" $stmsqaexport | tee -a $dbcopylog
echo "* STMS............:" $stmsexport | tee -a $dbcopylog
echo "* AL11............:" $al11export | tee -a $dbcopylog
echo "* BD54............:" $bd54export | tee -a $dbcopylog
echo "* FILE............:" $fileexport | tee -a $dbcopylog
echo "* RZ70/SLD........:" $rz70sldexport | tee -a $dbcopylog
echo "* SCOT............:" $scotexport | tee -a $dbcopylog
echo "* SICF............:" $sicfexport | tee -a $dbcopylog
echo "* RFC Connections.:" $rfcconnectionsexport | tee -a $dbcopylog
echo "* WE20/WE21/DB97..:" $we202197export | tee -a $dbcopylog
echo "* SM69............:" $sm69export | tee -a $dbcopylog
echo "* SMLG/RZ12.......:" $smlgrz12export | tee -a $dbcopylog
echo "* ABAP DEV........:" $abapdevexport | tee -a $dbcopylog
echo "* GTS/SLL.........:" $gtssllexport | tee -a $dbcopylog
echo "* OAC0............:" $oac0export | tee -a $dbcopylog
echo "* SCC4............:" $scc4export | tee -a $dbcopylog
echo "* Report Variants.:" $reportvariants | tee -a $dbcopylog
echo "* DBACOCKPIT......:" $dbacockpit | tee -a $dbcopylog
echo "* HTTPURLLOC......:" $httpurlloc | tee -a $dbcopylog
echo "* LDAP............:" $ldap | tee -a $dbcopylog
echo "* VSCAN...........:" $vscan | tee -a $dbcopylog
echo "* SPAD............:" $spad | tee -a $dbcopylog
echo "* EWZ5............:" $ewz5 | tee -a $dbcopylog
echo "* SBGRFCCONF......:" $sbgrfcconf | tee -a $dbcopylog
echo "* SBWP............:" $sbwp | tee -a $dbcopylog
echo "* SECPOL..........:" $secpol | tee -a $dbcopylog
echo "* SM19............:" $sm19 | tee -a $dbcopylog
echo "* Custom Tables...:" $customtables | tee -a $dbcopylog
if [ $sendfinishmail == yes ];
then
echo "Send mail to......:" $mailadress | tee -a $dbcopylog
fi
echo "====================================" | tee -a $dbcopylog
if [ $stmsqaexport == yes ];
then
echo "************************************" | tee -a $dbcopylog
echo "ATTENTION: PLEASE UPDATE STMS_QA IN SOURCE BEFORE PROCEEDING" | tee -a $dbcopylog
echo "************************************" | tee -a $dbcopylog
echo "====================================" | tee -a $dbcopylog
fi
# check if xuser is used or read passwords for db user
if [ $usexuser == yes ];
then
# set connectioninformation
export dbmcliconnetsource="-U $xusersource"
export dbmcliconnettarget="-U $xusertarget"
export dbmcliconnetsourcesql="-USQL $xusersource"
export dbmcliconnettargetsql="-USQL $xusertarget"
else
# read passwords
echo $dbsourceuser "password of" $sourcesid ":"
# switch off echo
stty -echo
read sysdbapwdsource
# switch on echo
stty echo
echo $dbtargetuser "password of" $targetsid" :"
# switch off echo
stty -echo
read sysdbapwdtarget
# switch on echo
stty echo
echo "===================================="
# set connectioninformation
export dbmcliconnetsource="-u '$dbsourceuser','$sysdbapwdsource'"
export dbmcliconnettarget="-u '$dbtargetuser','$sysdbapwdtarget'"
export dbmcliconnetsourcesql="-uSQL '$dbsourceuser','$sysdbapwdsource'"
export dbmcliconnettargetsql="-uSQL '$dbtargetuser','$sysdbapwdtarget'"
fi
# db size informations and checks
sshsource 'dbmcli -d '$sourcesid' '"$dbmcliconnetsource"' -o /tmp/dbcopy_dbsizesource_'$sourcesid' info state'
sshtarget 'dbmcli -d '$targetsid' '"$dbmcliconnettarget"' -o /tmp/dbcopy_dbsizetarget_'$targetsid' info state'
export sourcesizekberror=$(sshsource 'grep "ERR" /tmp/dbcopy_dbsizesource_'$sourcesid'' | wc -l)
export sourcesizekb=$(sshsource 'grep "Data" /tmp/dbcopy_dbsizesource_'$sourcesid' | grep KB | grep -v Perm | grep -v Temp | grep -v Max' | awk '{ print $4 }')
export sourcesizemb=$(echo "scale=0;0$sourcesizekb/1024" | bc -l)
export targetmaxsizekberror=$(sshtarget 'grep "ERR" /tmp/dbcopy_dbsizetarget_'$targetsid'' | wc -l)
export targetmaxsizekb=$(sshtarget 'grep "Data Max" /tmp/dbcopy_dbsizetarget_'$targetsid' | grep KB' | awk '{ print $5 }')
export targetmaxsizemb=$(echo "scale=0;0$targetmaxsizekb/1024" | bc -l)
# check source db
if [ $sourcesizekberror -ge 1 ];
then
# message
echo "source database not available --> EXIT (RC=97)"
# logfile
echo "source database not available --> EXIT (RC=97) "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# remove lockfile
rm -f $copylockfile
# cleanup
sshtarget 'rm /tmp/dbcopy_dbsizetarget_'$targetsid''
sshsource 'rm /tmp/dbcopy_dbsizesource_'$sourcesid''
# send mail bath
sendmailbatch
exit 97;
else
# size check
if [ 1$sourcesizemb -gt 1$targetmaxsizemb ];
then
# check target db
if [ $targetmaxsizekberror == 0 ];
then
# message
echo "Size of source data in MB..........: " $sourcesizemb
echo "Maxsize of target database in MB...: " $targetmaxsizemb
echo "Error source database size bigger than target max database size --> EXIT (RC=96)"
# logfile
echo "Size of source data in MB..........: " $sourcesizemb " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "Maxsize of target database in MB...: " $targetmaxsizemb " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "Error source database size bigger than target max database size --> EXIT (RC=96) "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# remove lockfile
rm -f $copylockfile
# cleanup
sshtarget 'rm /tmp/dbcopy_dbsizetarget_'$targetsid''
sshsource 'rm /tmp/dbcopy_dbsizesource_'$sourcesid''
exit 96;
else
# message
sleep 1
echo "Error - target database not available in state online"
echo ""
echo "Anyway, you can continue copy the system at your own risk!"
echo ""
echo "===================================="
# logfile
echo "Error target database not available, cannot check size "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "Anyway, you can continue copy the system at your own risk! "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "==================================== "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# set noexport
export donotexport=1
fi
else
# message
sleep 1
echo "Size of source data in MB..........: " $sourcesizemb
echo "Maxsize of target database in MB...: " $targetmaxsizemb
echo "===================================="
# logfile
echo "Size of source data in MB..........: " $sourcesizemb " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "Maxsize of target database in MB...: " $targetmaxsizemb " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "====================================" >> $dbcopylog
# write E070L from source into log
echo "E070L from "$targetsid $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
sshtarget 'sqlcli -U DEFAULT -f "SELECT * FROM E070L"' &>> $dbcopylog
echo "====================================" >> $dbcopylog
# set noexport
export donotexport=0
fi
fi
# version check
sshsource 'dbmcli -d '$sourcesid' '"$dbmcliconnetsource"' -o /tmp/dbcopy_dbversion_'$sourcesid' dbm_version'
sshtarget 'dbmcli -d '$targetsid' '"$dbmcliconnettarget"' -o /tmp/dbcopy_dbversion_'$targetsid' dbm_version'
export sourceversion=$(sshsource 'grep BUILD /tmp/dbcopy_dbversion_'$sourcesid'' | awk -F"= " '{ print $2 }')
export targetversion=$(sshtarget 'grep BUILD /tmp/dbcopy_dbversion_'$targetsid'' | awk -F"= " '{ print $2 }')
# message
sleep 1
echo "Version of Source DB...............: " $sourceversion
echo "Version of Target DB...............: " $targetversion
if [ "$sourceversion" != "$targetversion" ];
then
echo "************************************"
echo "ATTENTION: PLEASE CHECK THE DB VERSIONS!"
echo "SOURCE <= TARGET = OK"
echo "SOURCE > TARGET = NOT OK"
echo "************************************"
fi
echo "===================================="
# logfile
echo "Version of Source DB...............: " $sourceversion " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "Version of Target DB...............: " $targetversion " "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
if [ "$sourceversion" != "$targetversion" ];
then
echo "************************************" $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "ATTENTION: PLEASE CHECK THE DB VERSIONS!" $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "SOURCE <= TARGET = OK" $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "SOURCE > TARGET = NOT OK" $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "************************************" $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
fi
echo "====================================" >> $dbcopylog
#
# security question
if [ $enablebatch == no ];
then
echo "Start the Database-Copy from "$sourcesid" to "$targetsid" ?"
echo "WARNING: "$targetsid"-DB will be overwritten!"
echo "===================================="
read -r -p "Are you sure? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
# message
echo "Start the Database-Copy!"
echo "===================================="
# log
echo "Start the Database-Copy! "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "====================================" >> $dbcopylog
;;
*)
# message
echo "Stopping now & Cleanup! (RC=0)"
# log
echo "Stopping now & Cleanup! (RC=0) " $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# remove lockfile
rm -f $copylockfile
# cleanup
sshtarget 'rm /tmp/dbcopy_dbsizetarget_'$targetsid''
sshsource 'rm /tmp/dbcopy_dbsizesource_'$sourcesid''
exit 0
;;
esac
elif [ $enablebatch == yes ];
then
# message
echo "Batchmode is active"
echo "===================================="
# log
echo "Batchmode is active " $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "====================================" >> $dbcopylog
fi
# START #################################################################################################
# time and date
echo "START DB COPY: " $(date "+%d.%m.%Y %H:%M:%S") & export starttime=$(date +%s)
echo "START DB COPY: " $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
echo "===================================="
echo "====================================" >> $dbcopylog
# cleanup files no longer used
sshtarget 'rm /tmp/dbcopy_dbsizetarget_'$targetsid''
sshsource 'rm /tmp/dbcopy_dbsizesource_'$sourcesid''
if [ $savesecdir == yes ];
then
# message
echo "Save SEC dir"
# logfile
echo "Save SEC dir "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# save secdir
if [ $abaporjava == abap ];
then
sshtarget 'cd /usr/sap/$SAPSYSTEMNAME/D[0-9][0-9]; cp -rp sec syscopy_sec' >> $dbcopylog
export savesecdirpath=$(sshtarget 'cd /usr/sap/$SAPSYSTEMNAME/D[0-9][0-9]; cd syscopy_sec; pwd')
echo "SEC dir of "$targetsid" was saved to "$savesecdirpath" on "$targethost $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
elif [ $abaporjava == java ];
then
sshtarget 'cd /usr/sap/$SAPSYSTEMNAME/J[0-9][0-9]; cp -rp sec syscopy_sec' >> $dbcopylog
export savesecdirpath=$(sshtarget 'cd /usr/sap/$SAPSYSTEMNAME/J[0-9][0-9]; cd syscopy_sec; pwd')
echo "SEC dir of "$targetsid" was saved to "$savesecdirpath" on "$targethost $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
else
export savesecdirpath='Cannot save secdir'
echo $savesecdirpath $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# message
echo "Please define if ABAP or JAVA, cannot save secdir"
# log
echo "Please define if ABAP or JAVA, cannot save secdir "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
fi
# message
echo "SEC dir saved"
# logfile
echo "SEC dir saved "$(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# function sleepandspace
sleepandspace
fi
if ( [ $e07lexport == yes ] || [ $licexport == yes ] || [ $rz10export == yes ] || [ $rz04export == yes ] || [ $strustexport == yes ] || [ $strustsso2export == yes ] || [ $stmsqaexport == yes ] || [ $stmsexport == yes ] || [ $al11export == yes ] || [ $bd54export == yes ] || [ $fileexport == yes ] || [ $rz70sldexport == yes ] || [ $scotexport == yes ] || [ $sicfexport == yes ] || [ $rfcconnectionsexport == yes ] || [ $we202197export == yes ] || [ $sm69export == yes ] || [ $smlgrz12export == yes ] || [ $abapdevexport == yes ] || [ $gtssllexport == yes ] || [ $oac0export == yes ] || [ $scc4export == yes ] || [ $reportvariants == yes ] || [ $dbacockpit == yes ] || [ $httpurlloc == yes ] || [ $ldap == yes ] || [ $vscan == yes ] || [ $spad == yes ] || [ $ewz5 == yes ] || [ $sbgrfcconf == yes ] || [ $sbwp == yes ] || [ $secpol == yes ] || [ $secstore == yes ] || [ $sm19 == yes ] || [ $customtables == yes ] ) && ( [ $donotexport -eq 0 ] );
then
# message
echo "Create Export Template File"
# logfile
echo "Create Export Template File " $(date "+%d.%m.%Y %H:%M:%S") >> $dbcopylog
# create export file header
echo "export" > /tmp/dbcopy_tmp_exporttables.tpl
echo "client = "$expimpclient >> /tmp/dbcopy_tmp_exporttables.tpl
echo "file = '"$exportlocation"/"$targetsid"_dbcopy_exporttables.dat'" >> /tmp/dbcopy_tmp_exporttables.tpl
# create a unsort list of tables to export
if [ $e07lexport == yes ];
then
for table in "${tables_e07lexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $licexport == yes ];
then
for table in "${tables_licexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $rz10export == yes ];
then
for table in "${tables_rz10export[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $rz04export == yes ];
then
for table in "${tables_rz04export[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $strustexport == yes ];
then
for table in "${tables_strustexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $strustsso2export == yes ];
then
for table in "${tables_strustsso2export[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $stmsqaexport == yes ];
then
for table in "${tables_stmsqaexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $stmsexport == yes ];
then
for table in "${tables_stmsexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $al11export == yes ];
then
for table in "${tables_al11export[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $bd54export == yes ];
then
for table in "${tables_bd54export[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $fileexport == yes ];
then
for table in "${tables_fileexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $rz70sldexport == yes ];
then
for table in "${tables_rz70sldexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $scotexport == yes ];
then
for table in "${tables_scotexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $sicfexport == yes ];
then
for table in "${tables_sicfexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi
if [ $rfcconnectionsexport == yes ];
then
for table in "${tables_rfcconnectionsexport[@]}"
do
echo $table >> /tmp/dbcopy_tmp_exporttables_unsort.tpl
done
fi