Skip to content

Comments

Support native backup/restore from/to s3#10126

Merged
potatoqualitee merged 19 commits intodevelopmentfrom
support_native_backup_restore_s3
Jan 31, 2026
Merged

Support native backup/restore from/to s3#10126
potatoqualitee merged 19 commits intodevelopmentfrom
support_native_backup_restore_s3

Conversation

@ClaudioESSilva
Copy link
Contributor

@ClaudioESSilva ClaudioESSilva commented Jan 30, 2026

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Support Backup/Restore to Amazon S3 #9254)
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (Invoke-ManualPester)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

Add native S3-compatible object storage backup support to dbatools, leveraging SQL Server 2022's new BACKUP TO URL with S3 capability. This enables backing up and restoring databases directly to AWS S3, MinIO, and other S3-compatible storage providers.

Approach

After brainstorming with @potatoqualitee

Parameter Changes:

  • Renamed AzureBaseUrl to StorageBaseUrl with backward-compatible alias
  • Renamed AzureCredential to StorageCredential with backward-compatible alias
  • Added new StorageRegion parameter for specifying AWS region

Affected Commands:

  • Backup-DbaDatabase - Full S3 backup support with URL format s3://endpoint/bucket/path
  • Restore-DbaDatabase - Restore from S3 URLs
  • Get-DbaBackupInformation - Read backup metadata from S3 paths
  • Test-DbaLastBackup - Validate S3 backups
  • Test-DbaBackupInformation - S3 URL validation
  • Read-DbaBackupHeader - Read headers from S3 backups
  • Invoke-DbaAdvancedRestore - To support S3 paths

Validation Improvements:

  • S3 backups require SQL Server 2022+ (VersionMajor >= 16)
  • MaxTransferSize blocked for Azure page blobs but allowed for S3 (5MB-20MB range)
  • MaxTransferSize for S3 requires CompressBackup to be enabled
  • BlockSize blocked for Azure page blobs but allowed for S3

Integration Tests:

  • New GitHub Actions workflow (integration-tests-s3.yml) using a MinIO container that creates an S3-like bucket
  • SQL Server 2022 container with TLS certificate configuration for SQLPAL trust store
  • Comprehensive Pester tests covering backup, restore, and validation scenarios

Commands to test

# Create S3 credential (AWS S3 or MinIO)
$s3Params = @{
    SqlInstance    = "sql2022"
    Name           = "s3://mybucket.s3.us-west-2.amazonaws.com/backups"
    Identity       = "S3 Access Key"
    SecurePassword = (ConvertTo-SecureString "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" -AsPlainText -Force)
}
New-DbaCredential @s3Params

# Backup to S3
$splatBackup = @{
    SqlInstance       = "sql2022"
    Database          = "MyDatabase"
    Type              = "Full"
    StorageBaseUrl    = "s3://mybucket.s3.us-west-2.amazonaws.com/backups/sql2022/MyDatabase"
    StorageCredential = "s3://mybucket.s3.us-west-2.amazonaws.com/backups"
    CompressBackup    = $true
}
Backup-DbaDatabase @splatBackup

# Restore database from S3 backup
$splatRestore = @{
    SqlInstance               = "sql2022"
    DatabaseName              = "MyDatabase_Restored"
    StorageCredential         = "s3://mybucket.s3.us-west-2.amazonaws.com/backups"
    MaintenanceSolutionBackup = $true
    ReplaceDbNameInFile       = $true
}
Get-DbaDbBackupHistory -SqlInstance "sql2022" -Database "MyDatabase" -Last | Restore-DbaDatabase @splatRestore

Learning

NOTE

As I had to implement this on a client, I also ran tests in a DEV environment with real AWS EC2 instances and S3 buckets.

@potatoqualitee
Copy link
Member

It's so beautiful 😍

@potatoqualitee potatoqualitee merged commit 6da9604 into development Jan 31, 2026
16 checks passed
@potatoqualitee potatoqualitee deleted the support_native_backup_restore_s3 branch January 31, 2026 01:56
@potatoqualitee
Copy link
Member

Tres bien, merci! 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Backup/Restore to Amazon S3

2 participants