This page describes how to migrate your SQL Server databases to Cloud SQL for SQL Server instance with Database Migration Service.
The migration process involves the following tasks:
Exporting full database backup, and transaction log files from the source SQL Server instance.
You can also use the optional differential database backup in your migration process.
Uploading your backup files to a Cloud Storage bucket.
Creating the destination Cloud SQL for SQL Server instance.
Creating and running the migration job in Database Migration Service.
Monitoring the migration job progress with Database Migration Service observability features.
Promoting the migration job after the data is fully migrated.
Costs
For homogenous migrations to Cloud SQL, Database Migration Service is offered at no additional charge. However, Cloud SQL and Cloud Storage pricing applies for network charges as well as Cloud SQL and Cloud Storage entities created for migration purposes.
In this document, you use the following billable components of Google Cloud:
- Cloud Storage
- Cloud SQL
To generate a cost estimate based on your projected usage, use the pricing calculator.
Before you begin
- Verify if this migration path can fully support your scenario. See SQL Server Known limitations.
- Consider in which region you want to create the destination database. Database Migration Service is a fully-regional product, meaning all entities related to your migration (source and destination connection profiles, migration jobs, destination databases, storage buckets) must be saved in a single region.
- In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
- Enable the Database Migration Service, Compute Engine, Cloud Storage, and Cloud SQL Admin APIs.
Required roles
To get the permissions that you need to perform homogeneous SQL Server migrations with Database Migration Service, ask your administrator to grant the required IAM roles on your project for the following accounts involved in the migration process
- User account that performs the migration:
-
Database Migration Admin (
roles/datamigration.admin
) -
Storage Admin (
roles/storage.admin
) -
Cloud SQL Editor (
roles/cloudsql.editor
)
-
Database Migration Admin (
- Database Migration Service service account:
-
Database Migration Admin (
roles/datamigration.admin
) -
Storage Admin (
roles/storage.admin
) -
Cloud SQL Editor (
roles/cloudsql.editor
) -
Cloud SQL Studio User (
roles/cloudsql.studioUser
)
-
Database Migration Admin (
For more information about granting roles, see Manage access.
These predefined roles contain the permissions required to perform homogeneous SQL Server migrations with Database Migration Service. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to perform homogeneous SQL Server migrations with Database Migration Service:
- User account that performs the migration:
datamigration.*
resourcemanager.projects.get
resourcemanager.projects.list
cloudsql.operations.get
cloudsql.instances.create
cloudsql.instances.get
cloudsql.instances.list
cloudsql.instances.import
cloudsql.databases.get
cloudsql.databases.list
cloudsql.databases.delete
compute.machineTypes.list
compute.machineTypes.get
compute.projects.get
storage.buckets.create
storage.buckets.list
- Database Migration Service service account:
datamigration.*
resourcemanager.projects.get
resourcemanager.projects.list
cloudsql.instances.create
cloudsql.instances.get
cloudsql.instances.list
cloudsql.instances.executeSql
storage.objects.create
storage.objects.list
You might also be able to get these permissions with custom roles or other predefined roles.
Prepare your source data
To prepare your source data for migration, follow these steps:
Consider your backup strategy for the migration process. Database Migration Service supports using a differential backup and the transaction log files for migrating data that appears in your database after you take the full backup.
Perform a full backup of your source SQL Server database. Make sure you use the correct naming pattern.
Prepare a Cloud Storage bucket and upload your backup files to it. Make sure you set up the necessary directory structure for each backup file type you want to use.
Create a source connection profile for the Cloud Storage bucket.
Prepare your Cloud SQL for SQL Server destination instance
To configure your destination Cloud SQL instance, perform the following steps:
Create and configure your Cloud SQL for SQL Server destination instance. Make sure you use enough compute and memory resources to cover your migration needs, and assign the Storage Admin (
roles/storage.admin
) role to the instance's service account.Create a destination connection profile for your Cloud SQL instance.
Create and run the migration job
To configure and run your migration, perform the following steps:
Create and run the migration job.
When you start the migration job, your destination Cloud SQL for SQL Server databases are put into recovery mode where they are fully managed by Database Migration Service. You can promote your destination instance when your data is fully migrated. After your destination instance is promoted, all the databases in that instance become fully operational. You also gain full write access to those databases.
You can monitor the migration progress, as well as your destination instance health with Database Migration Service observability features. See Migration job metrics.
Keep uploading new transaction log backup files to the Cloud Storage bucket.
To cover data that appears in your source database after you perform the full backup export, export transaction log backup files and upload them to the storage bucket. Database Migration Service automatically detects new files, reads their contents, and pushes the data to your destination instance. See Automate transaction log exports.
Finalize the migration
When you decide to switch your application to the new Cloud SQL for SQL Server instance, finalize the migration by following these steps:
- Stop all write operations on your source databases. You can switch them to read-only mode to retain operational functionality.
- Take the last transaction log backup, upload the file to your storage
bucket, and stop the incremental load phase in Database Migration Service.
You can achieve this result by performing one of the following actions:
- Stop your automated backup file uploads, or upload the last transaction log file. Monitor the unprocessed transaction log backups size to determine when Database Migration Service finishes processing that file.
- Optionally, you can upload a transaction log file whose name ends
in
.trn.final
suffix. Database Migration Service stops continuous loads when it detects a backup file whose name matches the.trn.final
suffix convention.When Database Migration Service finishes processing that file, migration job status changes to Ready to promote.
- Promote the migration job.
- (Optional) Verify migration data for completeness.