You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Try to enumerate S3 objects - may fail with SSL errors if certificate not trusted
479
+
try {
480
+
$s3Objects=Get-S3Object@splatListObjects
481
+
} catch {
482
+
if ($_.Exception.Message-like"*SSL*"-or$_.Exception.Message-like"*certificate*") {
483
+
Set-ItResult-Skipped -Because "SSL certificate validation failed for self-signed MinIO certificate. In production, use a trusted certificate or configure certificate trust."
484
+
return
485
+
}
486
+
throw
487
+
}
488
+
489
+
# PowerShell CAN enumerate S3 - this is the correct approach
490
+
$s3Objects| Should -Not-BeNullOrEmpty
491
+
$s3Objects.Key| Should -Contain "$($script:S3EnumFolder)/$($script:TestDbName5)_full1.bak"
492
+
$s3Objects.Key| Should -Contain "$($script:S3EnumFolder)/$($script:TestDbName5)_log1.trn"
493
+
494
+
# Now demonstrate using those paths with Get-DbaBackupInformation
Copy file name to clipboardExpand all lines: private/functions/Get-XpDirTreeRestoreFile.ps1
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,12 @@ function Get-XpDirTreeRestoreFile {
43
43
# Determine the correct path separator based on whether this is a URL or file system path
44
44
if ($Path-match'^https?://') {
45
45
$pathSep="/"
46
+
} elseif ($Path-match'^s3://') {
47
+
# S3 paths cannot be enumerated via T-SQL (xp_dirtree/dm_os_enumerate_filesystem don't support S3)
48
+
# SQL Server 2022+ supports S3 for BACKUP/RESTORE but has no built-in function to list S3 objects
49
+
# Return empty array - caller should handle S3 enumeration in PowerShell or use explicit file paths
50
+
Write-Message-Level Warning -Message "S3 paths cannot be enumerated using T-SQL. Use explicit file paths or PowerShell-based enumeration for S3 storage."
51
+
Stop-Function-Message "S3 path enumeration not supported. Path: $Path"
For S3 storage (SQL Server 2022+): S3 bucket contents cannot be enumerated using T-SQL. You must provide explicit file paths or use PowerShell's Get-S3Object cmdlet (from AWS.Tools.S3 module) to retrieve the list of backup files first, then pass them to this command. See examples for S3 usage patterns.
35
+
34
36
.PARAMETERDatabaseName
35
37
Defines the target database name for the restored database when different from the original name.
36
38
Use this when creating a copy of a production database for testing or when restoring to avoid name conflicts.
@@ -164,7 +166,7 @@ function Restore-DbaDatabase {
164
166
Use this for log shipping secondary servers or when you need read-only access during restore operations.
165
167
The directory must exist and be writable by the SQL Server service account for undo file creation.
166
168
167
-
.PARAMETERStorageCredential
169
+
.PARAMETERStorageCredential
168
170
Specifies the SQL Server credential name for authenticating to Azure blob storage or S3-compatible object storage during restore operations.
169
171
Use this when restoring from Azure blob storage or S3 backups that require authentication.
170
172
For Azure: The credential must contain valid Azure storage account keys or SAS tokens.
@@ -329,7 +331,7 @@ function Restore-DbaDatabase {
329
331
c:\DataFiles and all the log files into c:\LogFiles
Will restore the backup held at http://demo.blob.core.windows.net/backups/dbbackup.bak to server1\instance1. The connection to Azure will be made using the
335
337
credential MyAzureCredential held on instance Server1\instance1
@@ -344,7 +346,7 @@ function Restore-DbaDatabase {
344
346
345
347
Will restore the backup from S3-compatible storage to sql2022. Requires SQL Server 2022 or higher. The credential must be configured with Identity = 'S3 Access Key' and Secret containing the access key and secret key.
Demonstrates the recommended workflow for restoring from S3 storage. Since SQL Server cannot enumerate S3 bucket contents via T-SQL, you must first use PowerShell's Get-S3Object cmdlet to list backup files, then pass the full S3 URLs to Restore-DbaDatabase.
445
+
The StorageCredential parameter should reference a SQL Server credential configured for S3 access.
0 commit comments