
{"id":8204,"date":"2019-09-13T09:45:24","date_gmt":"2019-09-13T09:45:24","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/migrate-a-sql-server-database-to-an-aws-rds-instance\/"},"modified":"2026-11-03T19:29:29","modified_gmt":"2026-11-03T19:29:29","slug":"migrate-a-sql-server-database-to-an-aws-rds-instance","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/en-gb\/blogs\/migrate-a-sql-server-database-to-an-aws-rds-instance\/","title":{"rendered":"Migrate a SQL Server database to an AWS RDS instance"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>This blog explains how to move a Microsoft\u00a9&nbsp; SQL Server\u00a9&nbsp; database hosted&nbsp;on-premises (or on Amazon\u00a9&nbsp; EC2 or Azure\u00a9&nbsp; to Amazon Relational Database&nbsp;Service (RDS). This move requires backing up your SQL database to an AWS S3&nbsp;bucket and restoring the database on your AWS RDS instance from that S3 bucket.<\/p>\n<p>Previous versions of the Amazon RDS instance did not let you restore data from&nbsp;<strong>.bak<\/strong>&nbsp;files. As a result, users had to use Amazon Data Migration Services or&nbsp;use the <strong>Import and Export<\/strong>&nbsp;wizard to move data to and from AWS RDS.&nbsp;Amazon started support for Native Backup Restore in July 2016 and added the&nbsp;following stored procedures in MSDB database on RDS:<\/p>\n<p>&#8211; <strong>rds\\_backup\\_database<\/strong> \u2013 Back up a single database to an S3 bucket.<br \/>\n&#8211; <strong>rds\\_restore\\_database<\/strong>&nbsp;\u2013 Restore a single database from S3.<br \/>\n&#8211; <strong>rds\\_task\\_status<\/strong> \u2013 Track a running backup and restore task.<br \/>\n&#8211; <strong>rds\\_cancel\\_task<\/strong>&nbsp;\u2013 Cancel a running backup or restore task.<\/p>\n<p>\nThis blog discusses how to leverage the <strong>rds\\_restore\\_database<\/strong>&nbsp;procedure to&nbsp;restore a <strong>.bak<\/strong>&nbsp;file from S3 and how to use the <strong>rds\\_task\\_status&nbsp;<\/strong>procedure to monitor the restore progress while the AWS S3 sync command is used&nbsp;to upload the backup file to an AWS S3 bucket.<\/p>\n<p><strong>Prerequisites<\/strong><\/p>\n<p>To perform a migration, you should have the following prerequisites:<\/p>\n<p>&#8211;&nbsp;&nbsp; &nbsp;SQL Server Agent Proxy<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;AWS Command Line Interface (AWS CLI)<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;ProfileName (an AWS user with access to Amazon S3 and an S3 bucket including<br \/>\n&nbsp; &nbsp;the <em>aws_access_key_id<\/em>&nbsp;and <em>aws_secret_access_key<\/em>.)<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;AWS RDS instance with an appropriate option group with the <em>SQLSERVER_BACKUP_RESTORE o<\/em>ption mapped to it.<br \/>\n&#8211; &nbsp;PowerShell installation<\/p>\n<p>You also should have basic knowledge about SQL Server, creating an S3 bucket,&nbsp;creating an AWS user, granting access to an S3 bucket, and creating an RDS instance.<\/p>\n<p><strong>Solution<\/strong><\/p>\n<p>The following steps cover the solution in the following sections:<\/p>\n<p>1.&nbsp;&nbsp; &nbsp;Back up the database on the local server.<\/p>\n<p>2.&nbsp;&nbsp; &nbsp;Copy the backup file to an AWS S3 bucket.<\/p>\n<p>3.&nbsp;&nbsp; &nbsp;Restore the SQL backup in RDS from the S3 bucket.<\/p>\n<p><strong>Back up the database on the local server<\/strong><\/p>\n<p>You can use any method to take a backup locally. The following example uses a&nbsp;<strong>.bat<\/strong>&nbsp;script with a sqlcmd command that you can use as in any SQL agent job,&nbsp;in case you need to schedule the migration task:<\/p>\n<p><em>&nbsp; &nbsp; Sqlcmd -S SourceInstanceName -U sa -P password_here -Q<br \/>\n&nbsp; &nbsp; &#8220;Declare @DBName nvarchar(200)=&#8217;MigrationTestDB&#8217;<br \/>\n&nbsp; &nbsp; DECLARE @BackupLocation NVARCHAR(2000) = &#8216;C:\\Temp\\RDSmigration\\backup\\&#8217;+@DBName+<br \/>\n&nbsp; &nbsp; + REPLACE(CONVERT(VARCHAR(20), GETDATE(), 120) + &#8216;.bak&#8217;, &#8216;:&#8217;, &#8221;);<br \/>\n&nbsp; &nbsp; BACKUP DATABASE @DBName TO DISK = @BackupLocation with compression;&#8221;<\/em><\/p>\n<p><strong>Copy and upload the backup file to an AWS S3 bucket<\/strong><\/p>\n<p>You can do this by using the <em>AWS S3 copy<\/em>&nbsp;or <em>AWS S3 sync<\/em>&nbsp;commands. However, the&nbsp;sync command is very popular and widely used in the industry, so the following&nbsp;example uses it.<\/p>\n<p>By default, the AWS sync command does not delete files. It simply copies new or&nbsp;modified files to the destination. You can use the following PowerShell script&nbsp;in an SQL agent job. You need to run both the backup and this copy step by using&nbsp;an SQL agent proxy account configured to run <em>cmdExec<\/em>&nbsp;and the PowerShell&nbsp;subsystem.<\/p>\n<p><em>&nbsp;$LogDate = Get-Date -Format yyyy-MM-dd<br \/>\n&nbsp; &nbsp; $Global:LogFile = &#8220;C:\\Temp\\RDSmigration\\Logs\\$LogDate.log&#8221;<\/em><\/p>\n<p><em>&nbsp; &nbsp; $env:Path += &#8216;;C:\\Program Files\\Amazon\\AWSCLI\\bin&#8217;<\/em><\/p>\n<p><em>&nbsp; &nbsp; Set-AWSCredential -ProfileName backuptos3user<br \/>\n&nbsp; &nbsp; aws configure set aws_access_key_id AKIAVIH6FYWVO62BZ7QA<br \/>\n&nbsp; &nbsp; aws configure set aws_secret_access_key pATGeYmJNsJNJTnf3hgQMk8gi5ekOerB\/\/JBCkzV<br \/>\n&nbsp; &nbsp; aws configure set region ap-south-1<\/em><br \/>\n&nbsp;try<br \/>\n&nbsp; <em>&nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;$now = (Get-Date -Format G)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;aws s3 sync C:\\Temp\\RDSmigration\\backup s3:\/\/ ramkrdsrestore &#8211;sse | out-file $LogFile<br \/>\n&nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; catch {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;Write-Host $_.Exception.Message -ForegroundColor Green<br \/>\n&nbsp; &nbsp; }<\/em><\/p>\n<p><strong>&nbsp;Restore the SQL backup in RDS from the S3 bucket<\/strong><\/p>\n<p>Run the following command to restore the <strong>MigrationTestDB2019-08-15 181640.bak&nbsp;<\/strong>file as the <strong>MigrationTestDB<\/strong>&nbsp;database:<\/p>\n<p>&nbsp; <em>&nbsp; EXEC msdb.dbo.rds_restore_database<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;@restore_db_name = &#8216;MigrationTestDB&#8217;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;@S3_arn_to_restore_from = &#8216;arn:aws:s3:::ramkrdsrestore\/MigrationTestDB2019-08-15 181640.bak&#8217;<\/em><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26621-body-Picture1_19.png\" alt=\"sql rds pic 1\" \/><\/p>\n<p>Note the parameters supplied to the stored procedure. You need to specify the&nbsp;following parameters:<\/p>\n<p>&#8211;&nbsp;&nbsp; &nbsp;The name of the database to restore.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;The Amazon Resource Name (ARN) of the backup file. For S3 objects, the ARN<br \/>\n&nbsp; &nbsp;follows the format shown here.<\/p>\n<p>&nbsp;SQL Server starts a restore task and assigns it a <strong>TaskID<\/strong>. You can easily&nbsp;track the status of the task with the following command:<\/p>\n<p><em>&nbsp; EXEC &nbsp;msdb.[dbo].[rds_task_status] &nbsp;@db_name =&#8217;DestinationDBName&#8217;<\/em><\/p>\n<p>You can use the <strong>TaskID<\/strong>&nbsp;to track progress instead of <strong>@db_name<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26621-body-Picture2_16.png\" alt=\"sql rds pic 2\" \/><\/p>\n<p>Be aware of the following concerns:<\/p>\n<p>&#8211;&nbsp;&nbsp; &nbsp;The bucket backup file name is case sensitive in the <strong>rds\\_restore\\_database&nbsp;<\/strong>procedure.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;The IAM role used in the option group has access to the S3 bucket.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;The S3 bucket policy is not restrictive to exclude the IAM role.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;The RDS SQL instance uses the correct option group where you added the&nbsp;backup\/restore option. This setting is critical. Without it, restore does not&nbsp;begin.&nbsp;<\/p>\n<p><strong>Limitations of SQL Server native backup and restore in Amazon RDS<\/strong><\/p>\n<p>Following are some limitations of SQL Server native backup and restore in Amazon&nbsp;RDS:<\/p>\n<p>&#8211;&nbsp;&nbsp; &nbsp;No differential, transaction log, filegroup backup, or restore is possible,&nbsp;&nbsp; &nbsp;which is not a hindrance to data recovery. Amazon RDS allows you to create scheduled instance snapshots, and those snapshots are kept accessible for a&nbsp;rolling 35-day period. You can restore the instance within five minutes of a&nbsp;specified time in the last thirty-five days.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;You cannot restore KMS-encrypted backups from S3 to on-premises.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;You cannot restore a database in the same RDS instance.<br \/>\n&#8211; &nbsp;You cannot restore backups of Tabular Data Encryption (TDE) enabled databases.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;Target RDS instances require access to the S3 bucket.<br \/>\n&#8211;&nbsp;&nbsp; &nbsp;The user account that is running RDS SQL Server native backup and restore&nbsp;commands needs to have appropriate permissions.<\/p>\n<p>&nbsp;<strong>Conclusion<\/strong><\/p>\n<p>This blog showed you how to back up a database on a cloud destination and to&nbsp;restore it on an AWS RDS instance. The RDS instance does not provide access to&nbsp;the drives or server. The key is to transfer a backup file to the AWS S3&nbsp;bucket and then restore it from there.<\/p>\n<p>One more use case for this article is to store your SQL backups directly on AWS&nbsp;S3, which provides data availability, security, and performance enhancements.&nbsp;Amazon S3 is designed for 99.999999999% (eleven 9s) durability. This approach&nbsp;is cost effective when it comes to storing database backups by saving a lot of&nbsp;hard storage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Migrate a SQL Server database to an AWS RDS instance<\/p>\n","protected":false},"author":2,"featured_media":8206,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26621","content_type":"blog","created_by":"10130","authored_on":"2024-02-19T10:45:24+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"by Ramkumar Singh, SQL Server Database Administrator, Rackspace Technology","seo_description":"Migrate your SQL Server database to Amazon Relational Database Service (RDS) using native backup restore.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26621-insights_image-general-architecture-technical-blog-5-insights.jpg","field_partners":"","rxt_platforms":"Amazon Web Services (AWS), Microsoft SQL","product":"","publisheddate":"2019-09-13T09:45:24","rxt_solutions":"Cloud Adoption & Migration, Databases","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"Migrate a SQL Server Database to an AWS RDS Instance | Rackspace Technology","field_topics":"","field_slug":"migrate-an-sql-server-database-to-an-aws-rds-instance","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-8204","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/8204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/comments?post=8204"}],"version-history":[{"count":3,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/8204\/revisions"}],"predecessor-version":[{"id":9955,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/8204\/revisions\/9955"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media\/8206"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media?parent=8204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/categories?post=8204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/tags?post=8204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}