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

Cannot create image from last full backup when source is another instance #193

Closed
blitzmann opened this issue May 3, 2022 · 1 comment
Closed

Comments

@blitzmann
Copy link
Contributor

blitzmann commented May 3, 2022

We have a production server called PROD01. It stores backups in it's local B:\ drive. When creating an image using the following command (using a production database and using the dev server as the restore surrogate)

New-DcnImage -SourceSqlInstance PROD01 -DestinationSqlInstance DEV01 -ImageNetworkPath \\dev01\g$\dbaclone-images\ -Database MyDatabase -UseLastFullBackup

This fails with a data access error

$lastFullBackup = Get-DbaDbBackupHistory -SqlInstance $SourceSqlInstance -SqlCredential $SourceSqlCredential -Database $db.Name -LastFull

This is the line that ultimately is the culprit. It's due to the fact that this reports the backup file in relation to the source server, so eg B:\SQL\Full\MyDatabase.bak. The dev server doesn't have this path (more specifically, this runs local to the script location, not the destination sql host, so if running locally on my machine, if I don't have B drive with this path, this will still fail, regardless of if the dev instance has access to it)

I have a solution that will replace B:\SQL\Full\MyDatabase.bak with UNC admin path \\PROD01\B$\SQL\Full\MyDatabase.bak. This works for our case specifically, but I'm not too familiar with the nuances of using the admin paths and drive$. I think ideally, the backup drives would be on a share, and we should replace the local drive letter with whatever that share is (although I'm not sure if it's possible to do that programmatically without giving the command specific locations)

I can submit a PR for my fix as a stop gap until someone can work out a more permanent solution

@blitzmann
Copy link
Contributor Author

I forgot to link the PR! /o\

This was merged with #194 :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant