Start-SqlMigration Error in dbatools-exception.txt #630

Open
Purclot opened this Issue Feb 2, 2017 · 4 comments

Projects

None yet

3 participants

@Purclot
Purclot commented Feb 2, 2017 edited

Is this a feature OR bug:

System Details

  • Operating system name and version: Windows Server 2012 DataCenter Evaluation
  • Output from $PSVersionTable:
Name                              Value                           
----                           -----                           
PSVersion                 5.0.10586.117                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                       
BuildVersion             10.0.10586.117                                                
CLRVersion                     4.0.30319.42000                                               
WSManStackVersion              3.0                                       
PSRemotingProtocolVersion      2.3                                      
SerializationVersion           1.1.0.1            
  • Output of dbatools version:
-----  -----  -----  --------
0      8      694    -1      
  • SQL Server version for source/target
    2008R2/2012; 2016

Steps to Reproduce

Start-SqlMigration -Verbose -Source Server2\DEV2012_1 -Destination Server2\DEV2016_1 -DetachAttach -Reattach -SetSourceReadOnly -Force

Action Results

######### Database: ReportServer$DEV2008_1 #########
VERBOSE: Checking for accessibility
VERBOSE: Checking Availability Group status
Started: 02/02/2017 14:10:16
Setting database to read-only
Update-SqldbReadOnly : Could not change readonly status for ReportServer$DEV2008_1 on Server2\DEV2008_1
At C:\Program Files\WindowsPowerShell\Modules\dbatools\0.8.694\functions\Copy-SqlDatabase.ps1:1102 char:17
+ ...            $result = Update-SqldbReadOnly $sourceserver $dbname $true
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-SqlDbReadOnly
Update-SqldbReadOnly : Could not change readonly status for ReportServer$DEV2008_1 on Server2\DEV2008_1
At C:\Program Files\WindowsPowerShell\Modules\dbatools\0.8.694\functions\Copy-SqlDatabase.ps1:1102 char:17
+ ...            $result = Update-SqldbReadOnly $sourceserver $dbname $true
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-SqlDbReadOnly

WARNING: Couldn't set database to read-only. Aborting routine for this database
######### Database: ReportServer$DEV2008_1TempDB #########

Expected Results

  1. The migration works fine, only the Database: ReportServer$MySqlServer (tested with 2008R2 and 2012) will not be set "Read-Only" on the source server.

It's not a big deal for me at all, maybe just try to correct the "try/catch" block in the function: Copy-SqlDatabase?

Attached Logs or any exception errors

  • Use of Start-Transcript can help collection of console output and exceptions
  • Certain commands will generate an exception log that you can find in following directory: dir $env:USERPROFILE\Documents\dbatools-exceptions.txt

Thanks for your comments
Purclot Avignon

@wsmelton
Member
wsmelton commented Feb 2, 2017

@Purclot The error you got was by design, the command was not able to mark the database as read-only.

The only thing being done when you use -SourceReadOnly is an internal function is called Update-SqlDbReadOnly that is simply executing the T-SQL statement: ALTER DATABASE [$dbname] SET READ_ONLY WITH NO_WAIT. That statement failed to execute for that database for some reason and therefore did not migrate that database.

@wsmelton wsmelton closed this Feb 2, 2017
@Purclot
Purclot commented Feb 2, 2017

@wsmelton: thanks. I know what happend was only not sure if it was intended. But: the database was successfully migrated(!), only not set read-only on source server - what is completely fine with me.

@wsmelton
Member
wsmelton commented Feb 2, 2017

AH, ok. Did not catch that...we may need to address that then. Would you expect it if it could NOT be set to read-only that it should not be migrated?

If that is the case we can likely fix that pretty easily.

@wsmelton wsmelton reopened this Feb 2, 2017
@Purclot
Purclot commented Feb 2, 2017

@wsmelton: 1) the problem emerges only with the ReportServer$Instance-DB (is created during the sql installation process). 2) I'd simply change the try/catch block saying "hey, the ReportServer-DB was imported but not set read-only on the source". Maybe some un-experienced PowerShell-User seeing the error message get the impression "all" went wrong..

@SirCaptainMitch SirCaptainMitch added the bug label Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment