简体   繁体   中英

Copy Azure SQL Database and Change Scale

We are using the command CREATE DATABASE X AS COPY OF Y to copy an Azure SQL database so that we can take a transactionally consistent backup to our local network. The database is running as a P2 so the copy is also created as a P2 and we are therefore incurring double charges due to daily rate charging of the new database sizes.

Is there any way to copy a database with a different scale setting? Or, are there other ways to take the transactionally consistent backup?

As far as I know currently the way to do the transactionally consistent backups is to either use the COPY command, which you are doing, or rely on the point in time Backup/Recovery provided by Microsoft. If your goal is simply to have the backup somewhere you may look at the GeoReplication options (standard and active) which gets the data into another region in Azure. If your requirements is definitely to get a local copy, the COPY + Export is pretty much your option.

There is not a way currently to perform a COPY from one Database tier level to another; however, in code you can change the tier level for a database, so in theory you could change the Copy to a lower tier immediately after the COPY (there is a sample on how do to this with PowerShell on MSDN using Set-AzureSqlDatabase). However, SQL Database is billed at the day, so you even if you change this immediately, you'd get charged for the P2 instance of the copy for that day. If you are doing these COPY-Export operations daily and deleting the Copy as soon as you get the export down then you won't be saving any money. They have announced that hourly billing is coming to SQL Database along with pricing changes and some other things. It looks like the new pricing will go into affect Nov 1st, and while it's not explicit, I'm assuming that means hourly billing then as well. With Hourly billing at least once you get the copy completed you can reduce the tier on the copy and only pay for that one hour, then after you pull down the export you can delete the copy and save money.

You can set the size of the DB during copy.

CREATE DATABASE db_copy 
  AS COPY OF ozabzw7545.db_original ( SERVICE_OBJECTIVE = 'P2' )  ; 

https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql?view=azuresqldb-current

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM