Esegui la migrazione dei database SQL Server a Cloud SQL per SQL Server
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come eseguire la migrazione dei database SQL Server all'istanza Cloud SQL per SQL Server con Database Migration Service.
La procedura di migrazione prevede le seguenti attività:
Esportazione del backup completo del database e dei file dei log delle transazioni dall'istanza SQL Server di origine.
Puoi anche utilizzare il backup differenziale facoltativo del database nel processo di migrazione.
Carica i file di backup in un bucket Cloud Storage.
Creazione dell'istanza Cloud SQL per SQL Server di destinazione.
Crea ed esegui il job di migrazione in Database Migration Service.
Monitoraggio dell'avanzamento del job di migrazione con le funzionalità di osservabilità di Database Migration Service.
Promuovi il job di migrazione dopo che i dati sono stati trasferiti del tutto.
Costi
Per le migrazioni omogenee a Cloud SQL, Database Migration Service viene offerto senza costi aggiuntivi. Tuttavia, i prezzi di Cloud SQL e Cloud Storage si applicano ai costi di rete, nonché alle entità Cloud SQL e Cloud Storage create a scopo di migrazione.
In questo documento utilizzi i seguenti componenti fatturabili di
Google Cloud:
Cloud Storage
Cloud SQL
Per generare una stima dei costi in base all'utilizzo previsto, utilizza il Calcolatore prezzi.
Prima di iniziare
Verifica se questo percorso di migrazione può supportare completamente il tuo scenario.
Consulta Limitazioni note di SQL Server.
Valuta in quale regione vuoi creare il database di destinazione.
Database Migration Service è un prodotto completamente regionale, il che significa che tutte le entità correlate alla migrazione (profili di connessione di origine e di destinazione, job di migrazione, database di destinazione, bucket di archiviazione) devono essere salvate in una singola regione.
Per ottenere le autorizzazioni necessarie per eseguire migrazioni omogenee di SQL Server con Database Migration Service, chiedi all'amministratore di concedere i ruoli IAM richiesti nel progetto per i seguenti
account coinvolti nel processo di migrazione
Per saperne di più sulla concessione dei ruoli, consulta
Gestire l'accesso.
Questi ruoli predefiniti contengono le autorizzazioni necessarie per eseguire migrazioni omogenee di SQL Server con Database Migration Service. Per visualizzare le autorizzazioni esatte
richieste, espandi la sezione Autorizzazioni richieste:
Autorizzazioni obbligatorie
Per eseguire migrazioni omogenee di SQL Server con Database Migration Service sono necessarie le seguenti autorizzazioni:
Account utente che esegue la migrazione:
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
Account di servizio di Database Migration Service:
Prepara l'istanza di destinazione Cloud SQL per SQL Server
Per configurare l'istanza Cloud SQL di destinazione, svolgi i seguenti passaggi:
Crea e configura l'istanza di destinazione Cloud SQL per SQL Server.
Assicurati di utilizzare risorse di calcolo e memoria sufficienti per soddisfare le tue esigenze di migrazione e assegna il ruolo Amministratore archiviazione (roles/storage.admin) all'account di servizio dell'istanza.
Quando avvii il job di migrazione, i database Cloud SQL per SQL Server di destinazione vengono messi in modalità di recupero, dove sono completamente gestiti da Database Migration Service. Puoi promuovere l'istanza di destinazione
quando la migrazione dei dati è stata completata. Dopo la promozione dell'istanza di destinazione, tutti i database al suo interno diventano pienamente operativi. Inoltre, ottieni accesso in scrittura completo a questi database.
Puoi monitorare l'avanzamento della migrazione, nonché lo stato dell'istanza di destinazione, con le funzionalità di osservabilità di Database Migration Service. Consulta
Metriche job di migrazione.
Continua a caricare nuovi file di backup dei log delle transazioni nel bucket Cloud Storage.
Quando decidi di passare la tua applicazione alla nuova istanza Cloud SQL per SQL Server, completa la migrazione seguendo questi passaggi:
Interrompi tutte le operazioni di scrittura sui database di origine. Puoi impostarli
in modalità di sola lettura per mantenere la funzionalità operativa.
Esegui l'ultimo backup del log delle transazioni, carica il file nel bucket di archiviazione e interrompi la fase di caricamento incrementale in Database Migration Service.
Per ottenere questo risultato, puoi eseguire una delle seguenti azioni:
Facoltativamente, puoi caricare un file di log delle transazioni il cui nome termina con il suffisso .trn.final. Database Migration Service interrompe i caricamenti continui quando rileva un file di backup il cui nome corrisponde alla convenzione di suffisso .trn.final.
Quando Database Migration Service termina l'elaborazione del file, lo stato del job di migrazione diventa
Pronto per la promozione.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-03 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."]]