dataplat / dbaclone

👯 Clone SQL Server databases using PowerShell previously named PSDatabaseClone
https://github.com/sqlcollaborative/dbaclone/wiki
MIT License
134 stars 29 forks source link

[New-DcnImage] Couldn't restore database System.Collections.Hashtable as MyDatabase-dbaclone on myserver. #226

Closed bdway closed 1 year ago

bdway commented 1 year ago

I have attempted to create the same image by running commands from the server and remotely from my machine. Both attempts have resulted in the same error and same end state.

Version 0.10.72

Error: WARNING: [07:12:02][New-DcnImage] Couldn't restore database System.Collections.Hashtable as Eligibility-dbaclone on mmappcore. Cannot find an overload for "Round" and the argument count: "1".

Results:

  1. The database looks to have been restored properly, I can still see it on the destination sql server.
  2. There is a vhdx file and a folder with the database mdf/ldf in the Image location. The file is the proper size and matches the database size.
  3. No records have been written to the dbaclone.dbo.Image table.
  4. The vhdx files cannot be deleted. I get an error that "the file is open by System"

Commands: New-DcnImage -BackupFilePath D:\Backup\Databases\MyDatabase\FULL -DestinationSqlInstance myserver -ImageNetworkPath \myserver\dbaclone\Images -Database MyDatabase

New-DcnImage -BackupFilePath D:\Backup\Databases\MyDatabase\FULL -DestinationSqlInstance myserver -ImageNetworkPath \myserver\dbaclone\Images -Database MyDatabase

I'm not a PowerShell expert and I'm not sure where to begin troubleshooting this Warning. Any tips or assistance would be greatly appreciated.

bdway commented 1 year ago

Here is the Verbose output. As soon as the restore hits 100% the warning gets displayed.

PS C:\WINDOWS\system32> New-DcnImage -Database MyDatabase -DestinationSqlInstance myserver -BackupFilePath \myserver\Databases\MyDatabase\FULL -ImageNetworkPath \myserver\dbaclone\Images -Verbose VERBOSE: [08:50:59][New-DcnImage] Setting vhd type to 'VHDX' VERBOSE: Performing the operation "Testing module setup" on target "Test-DcnConfiguration". VERBOSE: [08:50:59][Test-DcnConfiguration] Checking configurations VERBOSE: [08:50:59][Test-DcnConfiguration] Attempting to connect to dbaclone database server myserver.. VERBOSE: [08:51:02][Test-DcnConfiguration] Finished checking configurations VERBOSE: [08:51:02][New-DcnImage] Started image creation VERBOSE: Performing the operation "Converting UNC path to local path" on target "\myserver\dbaclone\Images". VERBOSE: [08:51:31][New-DcnImage] Converted '\myserver\dbaclone\Images' to 'D:\dbaclone\Images' VERBOSE: [08:51:31][New-DcnImage] Creating image for database System.Collections.Hashtable from \myserver\Databases\MyDatabase\FULL VERBOSE: Performing the operation "Checking available disk space for database" on target "System.Collections.Hashtable". VERBOSE: Performing the operation "Creating the vhd" on target "MyDatabase_20230327085131". VERBOSE: [08:51:31][New-DcnImage] Create the vhd MyDatabase_20230327085131 VERBOSE: Performing the operation "Initializing the vhd" on target "MyDatabase_20230327085131". VERBOSE: [08:51:35][New-DcnImage] Initializing the vhd MyDatabase_20230327085131 VERBOSE: Performing the operation "Creating access path D:\dbaclone\Images\MyDatabase_20230327085131" on target "D:\dbaclone\Images\MyDatabase_20230327085131". VERBOSE: Performing the operation "Adding access path 'D:\dbaclone\Images\MyDatabase_20230327085131' to mounted disk" on target "D:\dbaclone\Images\MyDatabase_20230327085131". VERBOSE: Performing the operation "Creating data folder in vhd" on target "D:\dbaclone\Images\MyDatabase_20230327085131". VERBOSE: [08:51:43][New-DcnImage] Creating data folder for image VERBOSE: Performing the operation "Creating log folder in vhd" on target "D:\dbaclone\Images\MyDatabase_20230327085131". VERBOSE: [08:51:43][New-DcnImage] Creating transaction log folder for image VERBOSE: Performing the operation "Restoring database" on target "MyDatabase-dbaclone". VERBOSE: [08:51:43][New-DcnImage] Restoring database System.Collections.Hashtable on myserver WARNING: [08:56:20][New-DcnImage] Couldn't restore database System.Collections.Hashtable as MyDatabase-dbaclone on myserver. Cannot find an overload for "Round" and the argument count: "1". VERBOSE: [08:56:20][New-DcnImage] Finished creating database image

bdway commented 1 year ago

I believe this issue was caused by having an additional sub folder with the previous backups in the -BackupFilePath location. I moved that folder out to a new location and the image operation has succeeded without issue several times.