Created
April 2, 2023 11:56
-
-
Save kdclaw3/f88716330c835dad5ae69531b770ec71 to your computer and use it in GitHub Desktop.
Backup MSSQL Server to S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @v_db nvarchar(255) = 'sample'; | |
declare @v_bkup_name nvarchar(255) = (select @v_db + format(sysdatetime(),'_yyyyMMdd_HHmm') + '.bak'); | |
declare @v_arn nvarchar(510) = 'arn:aws:s3:::sample-databasebackups/' + @v_bkup_name; | |
print '=====backing up database=====' | |
print 'database: ' + @v_db; | |
print 'filename: ' + @v_bkup_name; | |
print 'arn: ' + @v_arn; | |
exec msdb.dbo.rds_backup_database | |
@source_db_name= @v_db, --database name | |
@s3_arn_to_backup_to= @v_arn; --full s3 bucket with filename | |
/* | |
[@kms_master_key_arn='arn:aws:kms:region:account-id:key/key-id'], | |
[@overwrite_s3_backup_file=0|1], | |
[@type='DIFFERENTIAL|FULL'], | |
[@number_of_files=n]; | |
*/ | |
go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment