Changes for page migrate to managed instance
Last modified by Rudi Marais on 2024/03/28 18:51
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - migrate to managed instance1 +bacpac - Parent
-
... ... @@ -1,1 +1,1 @@ 1 - technical-documentation.analysis.sql.WebHome1 +Technical Documentation.analysis.sql.WebHome - Content
-
... ... @@ -1,172 +1,18 @@ 1 - 1 +* compressed file 2 +* contains ddl and dml data 3 +* doesnt support encrypted objects 2 2 3 -* sqlpackage 4 -** [[https:~~/~~/download.microsoft.com/download/7/c/8/7c877288-a0d9-4d22-b1dc-2086e262d82f/x64/DacFramework.msi>>https://download.microsoft.com/download/7/c/8/7c877288-a0d9-4d22-b1dc-2086e262d82f/x64/DacFramework.msi]] 5 -** [[https:~~/~~/learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download>>https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download]] 6 -** C:\Program Files\Microsoft SQL Server\160\DAC\bin 5 += = 7 7 8 - 9 -1. scale db to accetable performance ie dtus 500 10 - 11 -1. turn off real time scan (anti virus) 12 - 13 -1. run bcp extract scripts 14 -11. everest & docs parallel 15 -11. extract run from smallest to largest table 16 - 17 -1. run schema extracts 18 -11. not in parallel! 19 - 20 -1. create db 21 - 22 -1. create schemas 23 -11. prep scripts first 24 -11. document references 25 -11. make sure ddl audit triggers are disabled 26 - 27 -1. disable all indexes except clustered 28 - 29 -1. run imports [parallel] 30 -11. imports runs from smallest to largest table 31 - 32 - 33 -1. run extract with [[sql-script-db.ps1>>doc:technical-documentation.Source Control.migration.sql.sql-db-export.WebHome]] with validate set to true and raw objects set to true, only need tbl-triggers, functions and sp 34 -11. reason for this is to identify any procedure/triggers/functions that dont compile 35 -1. once this is done examine results and fix stored procedures on database so that they can compile, ie add missing columns or modify code to not require them 36 -11. repeat step 1 and 2 until you get zero objects that can't compile 37 -1. check sql code for any reserved varables ie... and fix on DB 38 -1. run dacpac export 39 -11. make sure nothing is running on source DB 40 -11. upgrade source DB to high level for quicker export and set back to what it was once done 41 -11. cmd 42 -1. run dacpac publish to managed instance 43 -1. 44 - 45 -* ((( 46 -(% class="wikigeneratedid" id="Hhttps:2F2Fgithub.com2Fmicrosoft2Fmssql-scripter" %) 47 -[[https:~~/~~/github.com/microsoft/mssql-scripter>>https://github.com/microsoft/mssql-scripter]] 48 - 49 -* C:\Users\alliancetest\.mssqlscripter 50 -* mssql-scripter -S "kula.database.windows.net" -d Everest_Test -U ebsadmin -P xxx -r -f E:\temp\khula_test.sql ~-~-display-progress ~-~-enable-toolsservice-logging 51 - 52 - 53 -))) 54 -* ALTER DATABASE Everest_Test SET READ_ONLY WITH NO_WAIT 55 - 56 - 57 -{{code language="sql"}} 58 --- index 59 -select concat('echo ''',SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.bcp ',SCHEMA_NAME(schema_id), '.', name , ''' >> test.log') 60 -from sys.tables 61 -where type = 'U' 62 -and is_ms_shipped = 0 63 - 64 ---and temporal_type in (0,2); 65 - 66 --- export 67 - 68 -select '$path = "E:\temp\test\everest_test"' cmd union 69 -select '$server = "mytest.database.windows.net"' union 70 -select '$username = "sa"' union 71 -select '$password = "123456"' union 72 -select 'New-Item -ItemType Directory -Force -Path "$path\export_log"' union 73 -select 'New-Item -ItemType Directory -Force -Path "$path\data"' 74 - 75 -select export = concat('bcp "', DB_NAME(), '.', 76 - SCHEMA_NAME(schema_id), '.', replace(name,'$','`$'), 77 - '" out "$path\data\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.bcp" ', 78 - ' -e "$path\export_log\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.log" ', 79 - ' -S "', '$server','"', 80 - ' -N -U "$username" -P "$password"', 81 - ' | Out-Null') 82 -from sys.tables 83 -where type = 'U' 84 -and is_ms_shipped = 0 85 ---and temporal_type in (0,2); 86 - 87 --- import 88 - 89 -select '$path = "E:\temp\test\everest_test"' cmd union 90 -select '$target_server = "sqlmi-ebs-prod.public.2a5fe6cde9a7.database.windows.net,3342"' union 91 -select '$target_db = "TST_Staging_Everest"' union 92 -select '$target_username = "import_test"' union 93 -select '$target_password = ''123456''' union 94 -select 'New-Item -ItemType Directory -Force -Path "$path\import_log"' union 95 -select 'New-Item -ItemType Directory -Force -Path "$path\data"' 96 - 97 -select import = concat('bcp "', '$target_db', '.', 98 - SCHEMA_NAME(schema_id), '.', replace(name,'$','`$'), 99 - '" in "$path\data\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)) , '.bcp" ', 100 - ' -e "$path\import_log\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)) , '.log" ', 101 - ' -S "', '$target_server','"', 102 - ' -N -U "$target_username" -P "$target_password"', 103 - ' -b 1000 -E -k -N -q', 104 - ' | Out-Null') 105 -from sys.tables 106 -where type = 'U' 107 -and is_ms_shipped = 0 108 ---and temporal_type in (0,2); 109 - 110 -{{/code}} 111 - 112 - 113 -* disable anti-virus real time scan 114 -* 115 - 116 -(% class="wikigeneratedid" %) 117 -placeholder 118 - 119 119 = Exporting = 120 120 121 121 * no encrypted objects, they need to be decrypted or removed prior to exporting. 122 122 123 -SQL 2012 124 - 125 - 126 - 127 -EXEC sp_configure 'show advanced options', 1; 128 -GO 129 -RECONFIGURE; 130 -GO 131 - 132 -EXEC sp_configure 'xp_cmdshell',1 133 -GO 134 -RECONFIGURE 135 -GO 136 - 137 - 138 -EXEC XP_CMDSHELL 'net use O: ~\~\zagpebslab.file.core.windows.net\sqlshare /user:"localhost\zagpebslab" "access_key"' 139 - 140 -EXEC XP_CMDSHELL 'Dir O:' 141 - 142 - 143 -BACKUP DATABASE Everest_TEST 144 -TO DISK = N'O:\ENS_Everest_Test_20230721_1806.bak' 145 -WITH COMPRESSION, 146 -STATS = 10; 147 - 148 - 149 -GO 150 - 151 - 152 -SELECT 153 - session_id as SPID, command, a.text AS Query, start_time, percent_complete, 154 - dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time 155 -FROM sys.dm_exec_requests r 156 - CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a 157 -WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE') 158 - 159 -GO 160 - 161 - 162 162 = Importing = 163 163 164 164 165 165 = Modifying and Troubleshooting = 166 166 167 -* Get-FileHash 'C:\temp\lfs\LifeSense_Everest_Test2-2023-5-17-7-37\model.xml' 168 -** place in Origin.xml 169 -*** <Checksum Uri="/model.xml">DEADD2734B789135ED627061A385FC2C1096718A7D3398658DF9097196C1F571</Checksum> 170 170 171 171 == Recalculate Signature == 172 172 ... ... @@ -173,3 +173,5 @@ 173 173 * incubator/ebsphere.crm/ebs-devops-devops-sql/calc-signature-bacpac.ps1 174 174 * modify Origin.xml 175 175 ** Checksum attribute for model.xml 22 + 23 +