简体   繁体   中英

copy Azure SQL database (PaaS) to IaaS (SQL server on VM)

Is it possible to use Create Database [] as copy of [] to create a copy of database that is hosted as Azure SQL database (PaaS) towards IaaS (SQL server on VM)?

Can you recommend an alternative of Import/Export that can limit the downtime of such transition?

Reason for this migration is the restriction of cross databases queries in PaaS mode that complicate one-time migration towards new database used in newer application version process

The answer depends on whether you want to copy database schema, data, or both.

As Jaxidian said, ApexSQL tools can do the job but as far I know DataDiff will only synchronize database data, while Diff will synchronize schema.

Here is the article describing processes of copying database data:

If you want to copy both schema and data, process is described here:

There are lots of tools available that can accomplish this. Which one is best for you depends on your needs. However, the "Copy" feature in the Azure Portal will not accomplish this for you but can be a partial solution to the approach you finalize on.

I'll make the following assumptions:

  • You have an always-on 24/7 production load so there are no regularly/nightly/weekly/monthly maintenance windows
  • You can schedule a maintenance window but you wish to keep it as small as possible
  • You can easily configure your applications' connectionstrings
  • Your database isn't huge. Gigabytes is fine.
  • Your database is mostly static data (ie an incremental approach is much faster than a dump-and-fill)

If I were to do this today/right now, my approach would be like this (this is only one option):

  1. Use the Copy feature to make a copy of the database that I can use this as a staging area/reference point while minimizing the load on the Production database
  2. Create a backup (bacpac file) from the copied database
  3. Restore the bacpac file onto your IaaS-hosted SQL Server to form your base deployment
  4. Start your maintenance window and effectively put your database into read-only mode so the data is now no longer changing (lots of strategies on how to do this whether you turn applications off, revoke permissions, etc.)
  5. Use a tool such as ApexSQL Data Diff (Redgate and others have options) to compare data between the two databases and sync the data over to the new IaaS DB. Be careful - depending on your data needs you may have to tweak the generated scripts that sync the data.
  6. Verify that the new DB is now indeed a duplicate copy of your old DB (ApexSQL Data Diff can also help with this - several options exist here)
  7. Change connectionstrings on your apps to point to the new DB
  8. Turn applications back on and end your maintenance window.

So of course, if you do something like this, practice it numerous times and test the results numerous times well before your maintenance window. Get a good idea of the timing for everything, especially how long it will take for you to generate and restore the bacpac file. This is because you want to do that as late as possible before your maintenance window to minimize the time it takes to generate and run the final "Data Diff" script that you'll use. The longer that script takes, the longer your outage will be.

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