Migrations between SQL Servers can be laborious, and doing them manually leaves a lot of room for human error. Scripting a migration using the dbatools Powershell module is incredibly simple, quick and robust.
Prerequisites
Powershell with dbatools module installed:
Steps
Run the following Powershell:
$startDbaMigrationSplat = @{Source = 'sourceServer'Destination = 'destinationServer'BackupRestore = $trueSharedPath = '\\path\both-servers-can-access'}Start-DbaMigration @startDbaMigrationSplat -Force | Select * | Out-GridView
This will migrate everything associated with the source instance, to the destination instance (inc logins, linked servers, startup procs...), using a backup and restore method for moving the databases. Use the -Exclude flag (see documentation link below) to exclude bits you don't want to be migrated over
Resources
dbatools migration documentation: https://docs.dbatools.io/#Start-DbaMigration
YouTube vid demo of dbatools migration: https://www.youtube.com/watch?v=hg8tovMRX2k
Fix issues with Powershell: https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system
Stack Exchange article on migrations: https://dba.stackexchange.com/questions/258559/side-by-side-upgrade-and-migrate-sql
No comments:
Post a Comment