Skip to content

Commit 6500512

Browse files
Copy-DbaDatabase - Pass IgnoreFileChecks to Backup-DbaDatabase for UNC paths
When xp_fileexist fails (e.g. due to certificate issues), Test-DbaPath returns false. Copy-DbaDatabase already handles this gracefully with a "Trying anyway" message, but then called Backup-DbaDatabase without -IgnoreFileChecks, causing Backup-DbaDatabase to run its own Test-DbaPath check, fail, and abort. Adding -IgnoreFileChecks to the non-Azure Backup-DbaDatabase calls skips the redundant internal path check (Copy-DbaDatabase already validates paths) so the backup proceeds when the SQL Server service account can actually access the path. Fixes #10286 (do Copy-DbaDatabase) Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 7701da9 commit 6500512

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

public/Copy-DbaDatabase.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,10 +1239,18 @@ function Copy-DbaDatabase {
12391239
}
12401240

12411241
} else {
1242+
$splatBackup = @{
1243+
SqlInstance = $sourceServer
1244+
Database = $dbName
1245+
BackupDirectory = $SharedPath
1246+
FileCount = $numberfiles
1247+
CopyOnly = $CopyOnly
1248+
IgnoreFileChecks = $true
1249+
}
12421250
if ($AdvancedBackupParams) {
1243-
$backupTmpResult = Backup-DbaDatabase -SqlInstance $sourceServer -Database $dbName -BackupDirectory $SharedPath -FileCount $numberfiles -CopyOnly:$CopyOnly @AdvancedBackupParams
1251+
$backupTmpResult = Backup-DbaDatabase @splatBackup @AdvancedBackupParams
12441252
} else {
1245-
$backupTmpResult = Backup-DbaDatabase -SqlInstance $sourceServer -Database $dbName -BackupDirectory $SharedPath -FileCount $numberfiles -CopyOnly:$CopyOnly
1253+
$backupTmpResult = Backup-DbaDatabase @splatBackup
12461254
}
12471255
}
12481256

0 commit comments

Comments
 (0)