SQL Server Database Migration – DB-Migrate v2: Powershell Module to Migrate Databases

This is an update to the DB-Migrate (https://www.sqlservergeeks.com/sql-server-database-migration-db-migrate-a-powershell-module-to-migrate-databases/) powershell module to migrate database between sql instances.

The new version is available here DB-Migrate v1.

The Move-Database function can now be used to move database to remote instances. There are 4 new parameters

IsCopy It’s a Boolean variable when true will copy database files to new location. The default value is false.

Datafilepath It’s the new location for data files (*.mdf and *.ndf). The default value is empty string. It will only be used only when IsCopy is true.

Logfilepath It’s the new location for log files (*.ldf). The default value is empty string. It will only be used only when IsCopy is true.

DatafileCopyPath It’s the path where data files are to be copied. It is same as DataFilePath parameter in case databases are to be moved between instances on same computer. If the files are to be copied to remote computer specify a UNC path.

   

logfileCopyPath It’s the path where log files are to be copied. It is same as logFilePath parameter in case databases are to be moved between instances on same computer.  If the files are to be copied to remote computer specify a UNC path.

Example

The following function call will move all databases from AHMAD-PC\SQL2005 to Remote-PC\SQLExpress. The datafilecopypath and logfilecopypath are same as datafilepath and logfilepath respectively only difference is that they use UNC path of same location.

Move-Databases -SourceInstance "AHMAD-PC\SQL2005" -DestInstance "Remote-PC\SQLExpress" –IsCopy $true  -datafilepath "D:\Database\Data" -logfilepath "D:\Database\log" -DatafileCopyPath "\\Remote-PC\d$\Database\data"   -logfileCopyPath "\\Remote-PC\d$\database\log"

 
Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

   

One Comment on “SQL Server Database Migration – DB-Migrate v2: Powershell Module to Migrate Databases”

  1. Hi Ahmad

    Greetings

    It was very helpful Article about Powershell Module to Migrate Databases.Is there any way that we can Upgrade the Databases ,i.e Side By Side Upgrade from 2005 to 2008 using Powershell Scripts .Can you please share if you have any thing Like that. !

Leave a Reply

Your email address will not be published.