Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a duplicate SQL Server database on the same Amazon RDS

Background: I'm moving some clients to an AWS RDS SQL server instance. Each has two databases: one for their live data, and one for training data, which is a copy of their live data. The training database is kept up to date by routinely restoring it using the live database. Ideally these databases would be hosted on the same RDS instance, since they aren't that big and it would halve the cost of hosting.

The problem: Amazon has these limitations in their documentation:

You can't restore a backup file to the same DB instance that was used to create the backup file. Instead, restore the backup file to a new DB instance. Renaming the database is not a workaround for this limitation.

You can't restore the same backup file to a DB instance multiple times. That is, you can't restore a backup file to a DB instance that already contains the database that you are restoring. Renaming the database is not a workaround for this limitation.

So backing up the live database and restoring it to the training database as I normally would is out. Other than hosting two separate instances per client, what's my best option here?

like image 229
Aaron Avatar asked May 01 '18 09:05

Aaron


People also ask

Can one RDS instance have multiple databases?

Amazon RDS currently supports MySQL, MariaDB, PostgreSQL, Oracle, Microsoft SQL Server, and Amazon Aurora database engines. When creating a DB instance, some database engines require that a database name be specified. A DB instance can host multiple databases, or a single Oracle database with multiple schemas.

Does RDS support SQL Server replication?

Creating a SQL Server read replica doesn't require an outage for the primary DB instance. Amazon RDS sets the necessary parameters and permissions for the source DB instance and the read replica without any service interruption. A snapshot is taken of the source DB instance, and this snapshot becomes the read replica.


1 Answers

Great News:

The limitation listed previously in the RDS Documentation has been removed:

You can't restore a backup file to the same DB instance that was used to create the backup file. Instead, restore the backup file to a new DB instance. Renaming the database is not a workaround for this limitation.

You can't restore the same backup file to a DB instance multiple times. That is, you can't restore a backup file to a DB instance that already contains the database that you are restoring. Renaming the database is not a workaround for this limitation.

I have just tested this, and have been able to restore the same backup multiple times to different database names on the same RDS SQL Server without issue, using the msdb.dbo.rds_restore_database stored procedure as defined within the linked documentation.

like image 118
Danlance Avatar answered Sep 21 '22 17:09

Danlance