编写个powershell脚本
$server = '.'
$database = 'databaseName'
$s3Bucket = 's3bucket'
$backupPath = 'D:\BackupTask\data\'
$region = 'us-west-2'
# accessKey and secretKey can be removed if running on an EC2 instance and using IAM roles for security
$accessKey = ''
$secretKey = '' $timestamp = get-date -format yyyyMMddHHmmss
$fileName = "$database-$timestamp.bak"
$filePath = Join-Path $backupPath $fileName
$s3FilePath = "sql-server-bak\" + $fileName Backup-SqlDatabase -ServerInstance $server -Database $database -BackupFile $filePath
# AccessKey and SecretKey can be removed if running on an EC2 instance and using IAM roles for security
Write-S3Object -BucketName $s3Bucket -File $filePath -Key $s3FilePath -Region $region -AccessKey $accessKey -SecretKey $secretKey
Remove-Item $backupPath$database*.bak
命名为BackupToS3.ps1,将脚本添加到windows计划任务执行即可