Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy-DbaDatabase -SetSourceOffline sets source offline even if the copy wasn't successfull. #9546

Open
frodr1k opened this issue Nov 12, 2024 · 2 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@frodr1k
Copy link

frodr1k commented Nov 12, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Using Cop-DBaDatabase to Move a database to another server using the "-SetSourceOffline" option, it will still set the source offline even if the copy DIDN'T Go through. You can see it even tries to continue the process in the script without noticing the database isn't there.

Also I think this should throw an error instead of a warning so it can be picked up by a try/catch.

WARNING: [08:33:17][Copy-DbaDatabase] Failure attempting to restore to | Microsoft.Data.SqlClient.SqlError: There is
insufficient free space on disk volume 'E:' to create the database. The database requires 677288869888 additional free bytes, while only 515491758080 bytes are
available.
WARNING: [08:33:19][Copy-DbaDatabase] Failure setting to read-write on destination server | An exception occurred while executing
a Transact-SQL statement or batch.User does not have permission to alter database , the database does not exist, or the
database is not in a state that allows access checks.
ALTER DATABASE statement failed.
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update DatabaseOwnershipChaining for False on on .
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update Trustworthy to False for on .
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update BrokerEnabled to False for on .

Steps to Reproduce

PrePReq: Target server must have lack of diskspace to contain the whole database.

Copy-DbaDatabase -Source -Destination -BackupRestore -SharedPath \\ -SetSourceOffline -Database

Please confirm that you are running the most recent version of dbatools

2.1.26

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.19041.5007
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.5007
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

SQL2022

.NET Framework Version

PSChildName Version


Client 4.8.09037
Full 4.8.09037
Client 4.0.0.0

@frodr1k frodr1k added bugs life triage required New issue that has not been reviewed by maintainers labels Nov 12, 2024
@frodr1k
Copy link
Author

frodr1k commented Nov 12, 2024

GitHub removes the servernames since It looked like HTML-tags. Here is the error message again

WARNING: [08:33:17][Copy-DbaDatabase] Failure attempting to restore MYDATABASE to MYSERVER | Microsoft.Data.SqlClient.SqlError: There is
insufficient free space on disk volume 'E:' to create the database. The database requires 677288869888 additional free bytes, while only 515491758080 bytes are
available.
WARNING: [08:33:19][Copy-DbaDatabase] Failure setting MYDATABASE to read-write on destination server | An exception occurred while executing
a Transact-SQL statement or batch.User does not have permission to alter database 'MYDATABASE', the database does not exist, or the
database is not in a state that allows access checks.
ALTER DATABASE statement failed.
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update DatabaseOwnershipChaining for False on MYDATABASE on MYSERVER.
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update Trustworthy to False for MYDATABASE on MYSERVER.
WARNING: [08:33:19][Copy-DbaDatabase] Failed to update BrokerEnabled to False for MYDATABASE on MYSERVER.

@frodr1k
Copy link
Author

frodr1k commented Nov 12, 2024

STEPS TO REPRODUCE:

Copy-DbaDatabase -Source MYSOURCE -Destination MYDESTINATION -BackupRestore -SharedPath \MYSHARESERVER -SetSourceOffline -Database MYDATABASE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant