Migrar bases de datos de SQL Server a Cloud SQL para SQL Server
Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
En esta página se describe cómo migrar tus bases de datos de SQL Server a una instancia de Cloud SQL para SQL Server con Database Migration Service.
El proceso de migración implica las siguientes tareas:
Exportar una copia de seguridad completa de la base de datos y archivos de registro de transacciones de la instancia de SQL Server de origen.
También puedes usar la copia de seguridad diferencial de la base de datos opcional en tu proceso de migración.
Subir los archivos de copia de seguridad a un segmento de Cloud Storage.
Crea la instancia de Cloud SQL para SQL Server de destino.
Crear y ejecutar la tarea de migración en Database Migration Service.
Monitorizar el progreso de la tarea de migración con las funciones de observabilidad de Database Migration Service.
Promocionar la tarea de migración una vez que se hayan migrado todos los datos.
Costes
En el caso de las migraciones homogéneas a Cloud SQL, Database Migration Service se ofrece sin coste adicional. Sin embargo, se aplican los precios de Cloud SQL y Cloud Storage a los cargos de red, así como a las entidades de Cloud SQL y Cloud Storage creadas con fines de migración.
En este documento, se usan los siguientes componentes facturables de
Google Cloud:
Cloud Storage
Cloud SQL
Para generar una estimación de costes basada en el uso previsto, utiliza la calculadora de precios.
Ten en cuenta en qué región quieres crear la base de datos de destino.
Database Migration Service es un producto totalmente regional, lo que significa que todas las entidades relacionadas con tu migración (perfiles de conexión de origen y destino, tareas de migración, bases de datos de destino y cubos de almacenamiento) deben guardarse en una sola región.
Para obtener los permisos que necesitas para realizar migraciones homogéneas de SQL Server con Database Migration Service, pide a tu administrador que conceda los roles de gestión de identidades y accesos necesarios en tu proyecto a las siguientes
cuentas implicadas en el proceso de migración.
Para obtener más información sobre cómo conceder roles, consulta el artículo sobre cómo
gestionar el acceso.
Estos roles predefinidos contienen los permisos necesarios para realizar migraciones homogéneas de SQL Server con Database Migration Service. Para ver los permisos exactos que se necesitan, despliega la sección Permisos necesarios:
Permisos obligatorios
Para realizar migraciones homogéneas de SQL Server con Database Migration Service, se necesitan los siguientes permisos:
Preparar la instancia de destino de Cloud SQL para SQL Server
Para configurar la instancia de Cloud SQL de destino, sigue estos pasos:
Crea y configura tu instancia de destino de Cloud SQL para SQL Server.
Asegúrate de usar suficientes recursos de computación y memoria para cubrir tus necesidades de migración y asigna el rol de administrador de almacenamiento (roles/storage.admin) a la cuenta de servicio de la instancia.
Cuando inicies la tarea de migración, tus bases de datos de destino de Cloud SQL para SQL Server se pondrán en modo de recuperación, donde Database Migration Service las gestionará por completo. Puedes promocionar tu instancia de destino
cuando tus datos se hayan migrado por completo. Una vez que se haya promovido la instancia de destino, todas las bases de datos de esa instancia estarán operativas. También obtendrás acceso completo de escritura a esas bases de datos.
Puedes monitorizar el progreso de la migración, así como el estado de tu instancia de destino, con las funciones de observabilidad de Database Migration Service. Consulta las
métricas de tareas de migración.
Sigue subiendo nuevos archivos de copia de seguridad del registro de transacciones al segmento de Cloud Storage.
Cuando decidas cambiar tu aplicación a la nueva instancia de Cloud SQL para SQL Server, finaliza la migración siguiendo estos pasos:
Detén todas las operaciones de escritura en tus bases de datos de origen. Puedes cambiarlos al modo de solo lectura para mantener la funcionalidad operativa.
Haz la última copia de seguridad del registro de transacciones, sube el archivo a tu
cubo de almacenamiento y detén la fase de carga incremental en Database Migration Service.
Para conseguir este resultado, puedes realizar una de las siguientes acciones:
También puedes subir un archivo de registro de transacciones cuyo nombre termine con el sufijo .trn.final. Database Migration Service detiene las cargas continuas cuando detecta un archivo de copia de seguridad cuyo nombre coincide con la convención de sufijos .trn.final.
Cuando el servicio de migración de bases de datos termine de procesar ese archivo, el estado de la tarea de migración cambiará a Listo para promover.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[[["\u003cp\u003eThis guide outlines the process of migrating SQL Server databases to Cloud SQL for SQL Server using Database Migration Service, involving exporting backups, uploading them to Cloud Storage, creating a destination instance, and running a migration job.\u003c/p\u003e\n"],["\u003cp\u003eThe migration process requires specific IAM roles for both the user account performing the migration and the Database Migration Service account, such as Database Migration Admin, Storage Admin, and Cloud SQL Editor, to ensure proper permissions.\u003c/p\u003e\n"],["\u003cp\u003ePreparing for the migration involves performing full backups of the source SQL Server database, configuring a Cloud Storage bucket for backup files, and establishing connection profiles for both the source and destination.\u003c/p\u003e\n"],["\u003cp\u003eDatabase Migration Service offers cost-effective homogenous migrations at no additional charge, but users should be aware of the costs associated with Cloud SQL and Cloud Storage usage, as well as potential network charges.\u003c/p\u003e\n"],["\u003cp\u003eFinalizing the migration includes stopping write operations on the source database, taking and uploading the last transaction log backup, stopping the incremental load, and promoting the migration job to switch to the new Cloud SQL for SQL Server instance.\u003c/p\u003e\n"]]],[],null,["# Migrate your SQL Server databases to Cloud SQL for SQL Server\n\nThis page describes how to migrate your SQL Server databases to\nCloud SQL for SQL Server instance with Database Migration Service.\n\nThe migration process involves the following tasks:\n\n1. Exporting full database backup, and transaction\n log files from the source SQL Server instance.\n\n You can also use the optional differential database backup in your migration\n process.\n2. Uploading your backup files to a Cloud Storage bucket.\n\n3. Creating the destination Cloud SQL for SQL Server instance.\n\n4. Creating and running the migration job in Database Migration Service.\n\n5. Monitoring the migration job progress with Database Migration Service observability\n features.\n\n6. Promoting the migration job after the data is fully migrated.\n\nCosts\n-----\n\nFor homogenous migrations to Cloud SQL, Database Migration Service is offered\nat no additional charge. However, Cloud SQL and Cloud Storage pricing\napplies for network charges as well as Cloud SQL and Cloud Storage\nentities created for migration purposes.\n\nIn this document, you use the following billable components of\nGoogle Cloud:\n\n- Cloud Storage\n- Cloud SQL\n\nTo generate a cost estimate based on your projected usage, use the\n[pricing calculator](/products/calculator).\n\nBefore you begin\n----------------\n\n1. Verify if this migration path can fully support your scenario. See [SQL Server\n Known limitations](/database-migration/docs/sqlserver/known-limitations).\n2. 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.\n3. In the Google Cloud console, on the project selector page, select or [create a Google Cloud project](/resource-manager/docs/creating-managing-projects).\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n4. Enable the Database Migration Service, Compute Engine, Cloud Storage, and Cloud SQL Admin APIs. [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=compute.googleapis.com,datamigration.googleapis.com,sqladmin.googleapis.com,storage.googleapis.com)\n\n### Required roles\n\nTo get the permissions that you need to perform homogeneous SQL Server\nmigrations with Database Migration Service, ask your administrator to grant the\nrequired IAM roles on your project for the following\n[accounts involved in the migration process](/database-migration/docs/sqlserver/access-control)\n\n- User account that performs the migration:\n - [Database Migration Admin](/iam/docs/roles-permissions/datamigration#datamigration.admin) (`roles/datamigration.admin`)\n - [Storage Admin](/iam/docs/roles-permissions/storage#storage.admin) (`roles/storage.admin`)\n - [Cloud SQL Editor](/iam/docs/roles-permissions/cloudsql#cloudsql.editor) (`roles/cloudsql.editor`)\n- Database Migration Service service account:\n - [Database Migration Admin](/iam/docs/roles-permissions/datamigration#datamigration.admin) (`roles/datamigration.admin`)\n - [Storage Admin](/iam/docs/roles-permissions/storage#storage.admin) (`roles/storage.admin`)\n - [Cloud SQL Editor](/iam/docs/roles-permissions/cloudsql#cloudsql.editor) (`roles/cloudsql.editor`)\n - [Cloud SQL Studio User](/iam/docs/roles-permissions/cloudsql#cloudsql.studioUser) (`roles/cloudsql.studioUser`)\n\nFor more information about granting roles, see\n[Manage access](/iam/docs/granting-changing-revoking-access).\n\nThese predefined roles contain the permissions required to perform homogeneous\nSQL Server migrations with Database Migration Service. To see the exact permissions\nthat are required, expand the **Required permissions** section: \n\n#### Required permissions\n\nThe following permissions are required to perform homogeneous SQL Server\nmigrations with Database Migration Service:\n\n- User account that performs the migration:\n - `datamigration.* `\n - `resourcemanager.projects.get`\n - `resourcemanager.projects.list`\n - `cloudsql.operations.get`\n - `cloudsql.instances.create`\n - `cloudsql.instances.get`\n - `cloudsql.instances.list`\n - `cloudsql.instances.import`\n - `cloudsql.databases.get`\n - `cloudsql.databases.list`\n - `cloudsql.databases.delete`\n - `compute.machineTypes.list`\n - `compute.machineTypes.get`\n - `compute.projects.get`\n - `storage.buckets.create`\n - `storage.buckets.list`\n- Database Migration Service service account:\n - `datamigration.* `\n - `resourcemanager.projects.get`\n - `resourcemanager.projects.list`\n - `cloudsql.instances.create`\n - `cloudsql.instances.get`\n - `cloudsql.instances.list`\n - `cloudsql.instances.executeSql`\n - `storage.objects.create`\n - `storage.objects.list`\n\nYou might also be able to get these permissions with\n[custom roles](/iam/docs/creating-custom-roles) or other\n[predefined roles](/iam/docs/roles-permissions).\n\nPrepare your source data\n------------------------\n\nTo prepare your source data for migration, follow these steps:\n\n1. [Consider your backup strategy for the migration process](/database-migration/docs/sqlserver/supported-backup-files).\n Database Migration Service supports using a differential backup and the transaction log\n files for migrating data that appears in your database after you take the full\n backup.\n\n2. [Perform a full backup of your source SQL Server database](/database-migration/docs/sqlserver/export-backup-files).\n Make sure you use the correct naming pattern.\n\n3. [Prepare a Cloud Storage bucket and upload your backup files to it](/database-migration/docs/sqlserver/storage-buckets).\n Make sure you set up the necessary directory structure for each backup file type\n you want to use.\n\n4. [Create a source connection profile](/database-migration/docs/sqlserver/create-source-connection-profile) for the Cloud Storage bucket.\n\nPrepare your Cloud SQL for SQL Server destination instance\n----------------------------------------------------------\n\nTo configure your destination Cloud SQL instance, perform the following steps:\n\n1. [Create and configure your Cloud SQL for SQL Server destination instance](/database-migration/docs/sqlserver/create-cloud-sql-destination-instance).\n Make sure you use enough compute and memory resources to cover your migration needs,\n and assign the Storage Admin (`roles/storage.admin`) role to the instance's\n service account.\n\n2. [Create a destination\n connection profile](/database-migration/docs/sqlserver/create-destination-connection-profile) for your Cloud SQL instance.\n\nCreate and run the migration job\n--------------------------------\n\nTo configure and run your migration, perform the following steps:\n\n1. [Create and run the migration job](/database-migration/docs/sqlserver/create-migration-job).\n\n When you start the migration job, your destination Cloud SQL for SQL Server\n databases are put into recovery mode where they are fully managed by\n Database Migration Service. You can promote your destination instance\n when your data is fully migrated. After your destination instance is promoted,\n all the databases in that instance become fully operational. You also gain\n full write access to those databases.\n | **Note:** To you use a differential backup file in the migration process, you need to use a specific configuration when you create the migration job. You can upload the differential backup file at a later time- after you create the migration job, but before you start uploading transaction log files.\n\n You can monitor the migration progress, as well as your destination instance\n health with Database Migration Service observability\n features. See\n [Migration job metrics](/database-migration/docs/sqlserver/migration-job-metrics).\n2. Keep uploading new transaction log backup files to the Cloud Storage bucket.\n\n To cover data that appears in your source database after you perform\n the full backup export,\n [export transaction log backup files](/database-migration/docs/sqlserver/export-backup-files) and upload them to\n the storage bucket. Database Migration Service automatically detects new files,\n reads their contents, and pushes the data to your destination instance.\n See\n [Automate transaction log exports](/database-migration/docs/sqlserver/automate-backup-exports).\n\nFinalize the migration\n----------------------\n\nWhen you decide to switch your application to the new Cloud SQL for SQL Server\ninstance, finalize the migration by following these steps:\n\n1. Stop all write operations on your source databases. You can switch them to read-only mode to retain operational functionality.\n2. 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:\n - Stop your [automated backup file uploads](/database-migration/docs/sqlserver/automate-backup-exports), or upload the last transaction log file. Monitor the [unprocessed transaction log backups size](/database-migration/docs/sqlserver/migration-job-metrics) to determine when Database Migration Service finishes processing that file.\n - 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](/database-migration/docs/sqlserver/export-backup-files).\n\n When Database Migration Service finishes processing that file, migration\n job status changes to\n [**Ready to promote**](/database-migration/docs/sqlserver/migration-job-statuses#ready-to-promote).\n3. [Promote the migration job](/database-migration/docs/sqlserver/finalize-migration).\n4. (Optional) [Verify migration data](/database-migration/docs/sqlserver/verify-migration) for completeness."]]