This page describes how to migrate your Cloud SQL for SQL Server databases to Cloud SQL for SQL Server instance with Database Migration Service. With this migration flow, you can move your databases to another Cloud SQL for SQL Server in the same, or in a different, Google Cloud project. For instructions on how to migrate from self-managed or Amazon RDS sources, see Migration guide for self-hosted and Amazon RDS sources.
The migration process for Cloud SQL for SQL Server sources involves the following tasks:
Configuring your source Cloud SQL for SQL Server instance so that Database Migration Service can automatically export backup files to a Cloud Storage bucket.
Creating a source connection profile with Google Cloud CLI.
Creating the destination Cloud SQL for SQL Server instance.
Creating and running the migration job in Database Migration Service with Google Cloud CLI.
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 migrations between two Cloud SQL for SQL Server instances with Database Migration Service, ask your administrator to grant the required IAM roles to the accounts involved in the migration process in the relevant projects.
This scenario lets you migrate between two Cloud SQL for SQL Server instances that reside in different Google Cloud projects. If you want to migrate between instances in the same project, grant all the permissions in the same project. For more information about granting roles, see Manage access.
Roles and permissions in the source project
Grant the following roles to specific accounts on the Google Cloud project where your source Cloud SQL for SQL Server instance resides:
- User account that performs the migration:
-
Storage Admin (
roles/storage.admin) -
Cloud SQL Editor (
roles/cloudsql.editor)
-
Storage Admin (
- Database Migration Service service account of the destination instance project:
-
Cloud SQL Viewer (
roles/cloudsql.viewer) -
Cloud SQL Studio User (
roles/cloudsql.studioUser)
-
Cloud SQL Viewer (
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 (source project) section:
Required permissions (source project)
The following permissions are required to perform homogeneous SQL Server migrations with Database Migration Service:
- User account that performs the migration:
resourcemanager.projects.getresourcemanager.projects.listcloudsql.operations.getcloudsql.instances.createcloudsql.instances.getcloudsql.instances.listcloudsql.instances.importcloudsql.databases.getcloudsql.databases.listcloudsql.databases.deletecompute.machineTypes.listcompute.machineTypes.getcompute.projects.getstorage.buckets.createstorage.buckets.list
- Destination project Database Migration Service service account:
cloudsql.instances.exportcloudsql.instances.getcloudsql.instances.listcloudsql.instances.executeSql
You might also be able to get these permissions with custom roles or other predefined roles.
Roles and permissions in the destination project
Grant the following roles to specific accounts on the Google Cloud project where your destination Cloud SQL for SQL Server instance resides:
- 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 of the destination instance project:
-
Database Migration Admin (
roles/datamigration.admin) -
Cloud SQL Editor (
roles/cloudsql.editor) -
Cloud SQL Studio User (
roles/cloudsql.studioUser)
-
Database Migration Admin (
- Cloud SQL service account associated with the source instance:
Storage Object User (
roles/storage.objectUser)This permission is required to let your source Cloud SQL for SQL Server instance to save exported backup files to the Cloud Storage bucket you create in the destination project.
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 (destination project) section:
Required permissions (destination project)
The following permissions are required to perform homogeneous SQL Server migrations with Database Migration Service:
- User account that performs the migration:
datamigration.*resourcemanager.projects.getresourcemanager.projects.listcloudsql.operations.getcloudsql.instances.createcloudsql.instances.getcloudsql.instances.listcloudsql.instances.importcloudsql.databases.getcloudsql.databases.listcloudsql.databases.deletecompute.machineTypes.listcompute.machineTypes.getcompute.projects.getstorage.buckets.createstorage.buckets.list
- Database Migration Service service account:
datamigration.*resourcemanager.projects.getresourcemanager.projects.listcloudsql.instances.createcloudsql.instances.getcloudsql.instances.listcloudsql.instances.executeSqlstorage.objects.createstorage.objects.list
- Cloud SQL service account associated with the source instance:
storage.objects.createstorage.objects.liststorage.objects.get
You might also be able to get these permissions with custom roles or other predefined roles.
Prepare your source Cloud SQL instance
Create a Cloud Storage bucket in the destination Google Cloud project. This bucket is used to store backup log files exported from your source Cloud SQL for SQL Server instance.
- We recommend that you configure data retention period to be between
14and30days for these backup files. - The Cloud SQL service account associated with your source
instance needs the
Storage Object User (
roles/storage.objectUser) IAM role to write the backup files to this bucket. For more information on permissions for this migration flow, see the Required roles section.
- We recommend that you configure data retention period to be between
Create a source connection profile for the Cloud SQL for SQL Server source instance.
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.
Create a destination connection profile for your Cloud SQL instance.
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.
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.
- Promote the migration job.
- (Optional) Verify migration data for completeness.