Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Export/Backup DB from SQL Server on Amazon RDS

I have a SQL Server database on Amazon RDS. How can I export or Backup the database? when I try to I get an error:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) The EXECUTE permission was denied on the object 'xp_fixeddrives', database 'mssqlsystemresource', schema 'sys'.

What I'm basically trying to do is to export the database and then import it on to Amazon EC2 on EBS.

Haven't been able to find solution for past 2 or 3 days.

Please help!!!! :)

like image 590
user3480908 Avatar asked Nov 20 '14 07:11

user3480908


People also ask

Where do backups happen on RDS SQL Server?

The backup occurs directly from the S3 bucket. It uses native SQL Server backup functionality and support compression. Permissions are configured through AWS Identity and Access Management (IAM) roles. Multi-file backups are also supported.

How to export data from MS SQL Server to Amazon RDS?

To export data from MS SQL Server on Amazon RDS, you can use either of these choices: Amazon RDS supports native backup for SQL Server databases using the .bak file. Create a full backup of on-premises databases and store it on Amazon S3. Now, restore the backup file onto Amazon RDS DB instance running SQL Server.

How do I backup my RDS Database to Amazon S3?

You can then open the Amazon S3 console, choose the bucket in which you created the user database backup, and view the backup file. You can download this file, or use the user database backup file to restore to the same RDS SQL Server DB instance or in a new RDS DB instance.

Can I perform native log backups from SQL Server on Amazon RDS?

You can't perform native log backups from SQL Server on Amazon RDS. RDS supports native restores of databases up to 16 TB. Native restores of databases on SQL Server Express Edition are limited to 10 GB. You can't do a native backup during the maintenance window, or any time Amazon RDS is in the process of taking a snapshot of the database.

How to use bak backup files on RDS?

To use .bak backup files on RDS requires only a short configuration process on your RDS instance, and a couple of simple stored procedures already included by Amazon on every RDS SQL Server instance. Now, please note that native SQL Server-type backups are not the only options for backing up data on RDS SQL Server.


1 Answers

As of July, this can be achieved by the following:

  1. Under RDS Dashboard create a new option group with "SQLSERVER_BACKUP_RESTORE" option.

  2. Update your RDS instance to use the newly created option.

  3. Open SQL Management Studio, connect to RDS database and execute the following to kick off the backup:

USE [msdb]
GO

DECLARE   @return_value int

EXEC  @return_value = [dbo].[rds_backup_database]
      @source_db_name = 'your_database_name',
      @S3_arn_to_backup_to = 'arn:aws:s3:::your-bucket-name/folder/db.bak',
      @KMS_master_key_arn = NULL,
      @overwrite_S3_backup_file = NULL

SELECT    'Return Value' = @return_value

GO

To check the progress of the backup, run the following:

> USE [msdb] GO
> 
> DECLARE   @return_value int
> 
> EXEC  @return_value = [dbo].[rds_task_status]         @db_name =
> 'your_database_name',         @task_id = <<<found in result of previous query>>>
> 
> SELECT    'Return Value' = @return_value
> 
> GO

More information here: https://aws.amazon.com/blogs/aws/amazon-rds-for-sql-server-support-for-native-backuprestore-to-amazon-s3/

like image 154
Denis Stepanenko Avatar answered Oct 05 '22 01:10

Denis Stepanenko