Trendveris
Live Coverage
AI & ML

Resize Cloud SQL for SQL Server Storage with Database Migration Service

Use continuous replication and a short cutover to move Cloud SQL for SQL Server to a smaller disk after database files free up unused space.

Nov 02, 2026 | 3 min read
Sign in to save

Database migration can solve an ongoing storage problem

Database Migration Service (DMS) is useful well beyond moving a database into Google Cloud. For SQL Server teams, its support for Google Cloud Database Migration Service with Cloud SQL for SQL Server as a source makes it possible to use continuous replication for routine operations. That includes moving between Cloud SQL instances in one project, across projects, or across regions. The practical payoff: you can resize storage with a short cutover instead of taking the source instance offline for an extended period. That matters because database storage tends to grow and stay grown. Cloud SQL’s automatic storage increase helps prevent outages during traffic spikes, batch imports, index maintenance, or temporary staging work. Later, you might archive old records, remove obsolete data, or drop indexes you no longer need. SQL Server makes the space those changes free available for future writes, but that doesn’t mean the files or disk automatically shrink. Deleted data frees reusable space inside data files such as .mdf and .ndf; log truncation does the same for transaction log files (.ldf). The files can still occupy their previous peak size unless AUTO_SHRINK is enabled. That setting is generally discouraged in production because it can cause severe index fragmentation and add performance overhead. You can manually return unused file space with DBCC SHRINKFILE. But shrinking those files doesn’t reduce the provisioned size of the Cloud SQL persistent disk. If you don’t expect the database to use that capacity again soon, reducing the disk can cut storage costs. That’s especially relevant after archiving data to cold storage or BigQuery, recovering from a one-time spike caused by a runaway transaction or migration, or refactoring a large database, removing indexes, or applying compression. To see how much space each database file has allocated, uses, and leaves free, query sys.database_files:

SELECT
 DB_NAME() AS [DatabaseName],
 name AS [LogicalName],
 type_desc AS [FileType],
 -- Allocated size on disk (converted from 8KB pages to MB)
 CAST(size / 128.0 AS DECIMAL(18, 2)) AS [AllocatedSize_MB],
 -- Actually used space inside the file
 CAST(FILEPROPERTY(name, 'SpaceUsed') / 128.0 AS DECIMAL(18, 2)) AS [UsedSpace_MB],
 -- Free space left in the allocated file
 CAST((size - FILEPROPERTY(name, 'SpaceUsed')) / 128.0 AS DECIMAL(18, 2)) AS [FreeSpace_MB],
 -- Percentage of allocated space that is used
 CAST((FILEPROPERTY(name, 'SpaceUsed') * 100.0) / size AS DECIMAL(18, 2)) AS [SpaceUsed_Percent]
FROM sys.database_files;
Cloud Monitoring gives you two useful signals: database/disk/bytes_used reports space consumed by database files and logs, while database/disk/quota reports the instance’s provisioned disk capacity. A large gap between them may point to an opportunity to shrink.

Why use DMS for the move?

Cloud SQL has a built-in storage shrink feature, which is suitable when your workload can handle planned maintenance. The catch is that native shrinking takes the instance offline for a period tied to the disk’s total allocated size. On a multi-terabyte disk, that can mean hours of downtime.

If your production SLA can’t absorb that outage, DMS offers another route: replicate to a new Cloud SQL instance with a smaller disk while the application continues running, then switch over during a short window. The reason that window can be brief lies in how DMS keeps the destination up to date.

What DMS replicates

For Cloud SQL for SQL Server migrations, DMS coordinates a process similar to SQL Server log shipping: it restores an initial full backup of the selected user databases to the destination, then continuously captures and applies transaction log backups to keep them nearly synchronized.

1
  1. It takes an initial full backup (.bak) of the selected user databases and restores it on the target.
  2. It then captures and applies transaction log backups (.trn) continuously.

The replication boundary matters: DMS copies user databases, not the whole SQL Server instance. Logins, linked servers, SQL Server Agent jobs, and other server-level objects don’t automatically appear on the destination. You’ll need to move those separately.

Right-size the disk with a short cutover

The workflow moves the workload to a new instance instead of shrinking the existing disk in place. Provision the target with a smaller disk, but leave enough room for transaction logs and expected growth. Start a continuous DMS job with the current Cloud SQL instance as its source, and let replication catch up while production keeps running. For cutover, stop application traffic, wait for the final transaction log to apply, promote the target in DMS, and point the application to the new instance.

2

Native shrink and DMS migration compared

3

A short cutover still takes preparation. Because DMS migrates at the user-database level, a successful switch also depends on carrying over server settings and objects, then checking that database users can authenticate on the new instance.

Prepare server-level objects before cutover

Recreate server-level objects on the destination before switching traffic. For logins, script them from the source with sp_help_revlogin and create them on the target.

In SQL Server Management Studio (SSMS), connect to the source, select an object in Object Explorer, and use Script [Object] as > CREATE To > New Query Window / File to generate its script. Review and deploy the relevant objects:

  • SQL Server Agent jobs: Check SQL Server Agent > Jobs. Inspect job steps for on-premises file paths or unsupported operating system dependencies.
  • Linked servers: Script objects under Server Objects > Linked Servers. Before deploying, enable the cloudsql.linked_servers database flag on the destination instance.
  • Extended events: Script sessions under Management > Extended Events > Sessions.
  • TDE: For an instance using Transparent Data Encryption, export the TDE certificate from the source and import it to the destination before cutover.
  • Instance settings: Manually match database flags, Active Directory, Entra ID, and other instance configurations on the destination.
  • PolyBase: Re-encrypt the database master key (DMK) so database-scoped credentials continue to work.

Check for orphaned users after cutover

Database users authenticate through SQL Server logins. If a destination login is missing, misconfigured, or has a different security identifier (SID) from the source, the user can become orphaned when the migrated database comes online. Using sp_help_revlogin preserves SIDs during login migration; creating logins another way assigns new SIDs and can leave users orphaned.

For each destination database, run Microsoft’s diagnostic query from its Troubleshoot Orphaned Users Guide to find users without a matching server principal:

SELECT dp.type_desc, dp.sid, dp.name AS user_name
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid
WHERE sp.sid IS NULL AND dp.authentication_type_desc = 'INSTANCE';

For each user returned, run ALTER USER in that database to link it to the appropriate destination login and retain its permissions:

ALTER USER [user_name] WITH LOGIN = [login_name];

A day-two use for migration tooling

DMS is more than a one-time path into Google Cloud. It can also help Cloud SQL teams reduce provisioned storage when a lengthy native shrink would break production downtime limits. Continuous replication keeps the application online during the move, with the service switch limited to a short cutover.

For setup details, see the DMS documentation for Cloud SQL for SQL Server sources. If you’re new to SQL Server on Google Cloud, start with the Cloud SQL for SQL Server introduction.

Source: Nithin Tomson · cloud.google.com
Sign in to join the discussion.