Create a Windows application consistent disk snapshot Stay organized with collections Save and categorize content based on your preferences.
In Compute Engine, you can usesnapshotsto back up your disk data. Because snapshots are incremental, you cancreate them with higher performance and lower total storage charges compared tocreating complete disk images.
Application consistent snapshots capture the state of application data atthe time of backup with all application transactions completed and all pendingwrites flushed to the disk. On Windows VMs, you use the Volume Shadow CopyService (VSS) to create application consistent snapshots without first stoppingthe instance or detaching the disk from your VM.
Caution: If you have enabled BitLocker on a boot disk that is based on aShielded VMimage, you can restore a snapshot of that bootdisk to another disk, but you can't decrypt the restored instance.This is because the vTPM containing the BitLocker keys is only available to thevirtual machine (VM) instance that originated the snapshot. For moreinformation, seeUsing BitLocker with Shielded VM images.Before you begin
- Create a Windows instance.
- Review thebest practices for creating snapshots.
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Limitations
Disk snapshots on Windows have the following limitations:
- VSS snapshots work only on Windows instances with imageversion
v20160810and newer. For instances with older images,create a snapshot without using VSS. - The attached disk must use an NTFS, exFAT, or ReFS file system.
- VSS snapshots help to preserve your data only if you are running VSS-awareapplications that can coordinate to create a consistent backup of your data.
- If the VSS snapshot operation does not complete within 300 seconds, thesnapshot fails with a timeout error.
Create a Windows VSS snapshot
You can create Volume Shadow Copy Service (VSS) snapshots without having to stopthe instance or detach the disk from your VM. VSS snapshots are intended forbackup and recovery purposes on systems with VSS-aware apps.
VSS snapshots are the same price as normal Persistent Disk orHyperdisk snapshots, and charge only for thetotal size of the snapshot.
Create the snapshot
Console
Go to theCreate a Snapshot page in the Google Cloud console.
Go to the Create a Snapshot page- Enter a snapshotName.
Select aSnapshot type. The default is a
STANDARDsnapshot, which is the best option for long-term back up and disaster recovery.ChooseArchive snapshot for more cost-efficient data retention.
- Optional: Enter aDescription of the snapshot.
- UnderSource disk, select the existing disk that you want to create a snapshot of.
In theLocation section,choose your snapshot storage location.
The predefined or customized default location defined in your snapshot settings is automatically selected. Optionally, you can override the snapshot settings and store your snapshots in a custom storage location by doing the following:
Choose the type of storage location that you want for your snapshot.
- ChooseMulti-regional for higher availability at a higher cost.
- ChooseRegional snapshots for more control over the physical location of your data at a lower cost.
- In theSelect location field, select the specific region or multi-region that you want to use. To use the region or multi-region that is closest to your source disk, selectBased on disk's location.
- Check theEnable application consistent snapshot option.
- ClickCreate to create the snapshot.
gcloud
To create a VSS snapshot, use thegcloud compute snapshots create commandand include the--guest-flush flag.
You can create your snapshot in the storage location policydefined by yoursnapshot settings orusing an alternative storage location of your choice. For more information, seeChoose your snapshot storage location.
To create a snapshot in the predefined or customized default location configured in your snapshot settings, use the
gcloud compute snapshots createcommand.gcloud compute snapshots createSNAPSHOT_NAME \ --source-disk-zone=SOURCE_ZONE \ --source-disk=SOURCE_DISK_NAME \ --snapshot-type=SNAPSHOT_TYPE \ --guest-flush
Alternatively, to override the snapshot settings and create a snapshot in a custom storage location, include the
--storage-locationflag to indicate where to store your snapshot.gcloud compute snapshots createSNAPSHOT_NAME \ --source-disk-zone=SOURCE_ZONE \ --source-disk=SOURCE_DISK_NAME \ --snapshot-type=SNAPSHOT_TYPE \ --storage-location=STORAGE_LOCATION \ --guest-flush
(Preview) To create a regionally scoped snapshot in an allowed region, include the
--regionflag to indicate where to create your snapshot.gcloud beta compute snapshots createSNAPSHOT_NAME \ --region=SNAPSHOT_SCOPE_REGION --source-disk=SOURCE_DISK_NAME \ --source-disk-zone=SOURCE_ZONE \ --snapshot-type=SNAPSHOT_TYPE
Replace the following:
- SNAPSHOT_NAME: A name for the snapshot.
- SOURCE_ZONE: The zone of the source disk.
- SOURCE_DISK_NAME: The name of the disk volume from which you want to create a snapshot.
- SNAPSHOT_TYPE: The snapshot type, eitherSTANDARD orARCHIVE. If a snapshot type is not specified, a
STANDARDsnapshot is created. STORAGE_LOCATION: Optional: For globally scoped snapshots, theCloud Storage multi-region or theCloud Storage region where you want to store your snapshot. You can specify only one storage location.
Use the
--storage-locationparameter only when you want to override the predefined or customized default storage location configured in your snapshot settings.SNAPSHOT_SCOPE_REGION: Optional: For regionally scoped snapshots, the region that the snapshot is scoped to. If you include this parameter, you can't use the
--storage-locationparameter. TheSTORAGE_LOCATION is automatically set to theSNAPSHOT_SCOPE_REGION.
gcloud compute snapshots create command instead of thegcloud compute disks snapshot command because it supports more features, such as creating snapshots in a project different from the source disk project.To create a VSS snapshot of a regional Persistent Disk, in the previousexamples replace--source-disk-zone= with--source-disk-region=, and specify the region where your regionalPersistent Disk is located.
The Google Cloud CLI waits until the operation returns a status ofREADY,FAILED, or reaches the maximum timeout and returns the lastknown details of the snapshot.
REST
When creating a snapshot, to indicate that you want to create a VSSsnapshot, include theguestFlush property in therequest body for yourPOST request to thecompute.snapshots.insert method.
You can create your snapshot in the storage location policydefined by yoursnapshot settings orusing an alternative storage location of your choice. For more information, seeChoose your snapshot storage location.
To create a snapshot in the predefined or customized default location configured in your snapshot settings, make a
POSTrequest to thesnapshots.insertmethod:POST https://compute.googleapis.com/compute/beta/projects/DESTINATION_PROJECT_ID/global/snapshots{ "name": "SNAPSHOT_NAME", "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/SOURCE_DISK_NAME", "snapshotType": "SNAPSHOT_TYPE", "guestFlush": true,}Alternatively, to override the snapshot settings and create a snapshot in a custom storage location, make a
POSTrequest to thesnapshots.insertmethod and include thestorageLocationsproperty in your request:POST https://compute.googleapis.com/compute/beta/projects/DESTINATION_PROJECT_ID/global/snapshots{ "name": "SNAPSHOT_NAME", "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/SOURCE_DISK_NAME", "snapshotType": "SNAPSHOT_TYPE", "storageLocations": [ "STORAGE_LOCATION" ], "guestFlush": true,}(Preview) To create a regionally scoped snapshot in an allowed region, make a
POSTrequest to thesnapshots.insertmethod and define the creation region:POST https://compute.googleapis.com/compute/beta/projects/DESTINATION_PROJECT_ID/regions/SNAPSHOT_SCOPE_REGION/snapshots{ "name": "SNAPSHOT_NAME", "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/SOURCE_DISK_NAME", "snapshotType": "SNAPSHOT_TYPE"}
Replace the following:
- DESTINATION_PROJECT_ID: The ID of project in which you want to create the snapshot.
- SNAPSHOT_NAME: A name for the snapshot.
- SOURCE_PROJECT_ID: The ID of the source disk project.
- SOURCE_ZONE: The zone of the source disk.
- SOURCE_DISK_NAME: The name of the disk from which you want to create a snapshot.
- SNAPSHOT_TYPE: The snapshot type, eitherSTANDARD orARCHIVE. If a snapshot type is not specified, a
STANDARDsnapshot is created. STORAGE_LOCATION: Optional: For globally scoped snapshots, theCloud Storage multi-region or theCloud Storage region where you want to store your snapshot. You can specify only one storage location.
Use the
storageLocationsparameter only when you want to override the predefined or customized default storage location configured in your snapshot settings.SNAPSHOT_SCOPE_REGION: Optional: For regionally scoped snapshots, the region that the snapshot is scoped to. If you include this parameter, you can't use the
storageLocationsparameter. TheSTORAGE_LOCATION is automatically set to theSNAPSHOT_SCOPE_REGION.
snapshots.insert method instead of thedisks.createSnapshot method because it supports more features, such as creating snapshots in a project different from the source disk project.To create a VSS snapshot of a regional Persistent Disk, in thePOST requestsshown previously, replace the following line:
"sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/SOURCE_DISK_NAME",
"sourceDisk": "projects/SOURCE_PROJECT_ID/regions/SOURCE_REGION/disks/SOURCE_DISK_NAME",
Create a writable disk from a VSS snapshot
When you create a VSS snapshot, Windows Server marks the volume in the snapshotas read-only. When you create a new disk from the VSS snapshot,that disk is also set to read-only mode.
This might cause issues. For example, if you create a VM instance with a newboot disk from a VSS snapshot of an existing boot disk, the read-only flag onthe new boot disk prevents the VM from booting correctly.
To work around this issue, remove the read-only flag from any new disk that youcreate from a VSS snapshot using the following steps:
Make sure the disk is attached to a VM:
- If the disk that you created from the VSS snapshot is anon-boot data disk, you can attach the disk to any new or existing VM.
- If the disk that you created from the VSS snapshot is aboot disk andyou want to use it to boot a VM, then you must temporarily attach thedisk to a separate, existing VM. After you complete the followingsteps, you can detach the disk from that VM and use it toboot a new VM instance.
Sign in to the Windows VMthat the disk is attached to.
Open a PowerShell command prompt and run the
diskparttool.PS C:\>diskpartIdentify the disk that you want to mount.
DISKPART>list diskUse the
select diskcommand to select the disk.DISKPART>select diskDISK_NUMBERReplace
DISK_NUMBERwith the number of the disk that youwant to mount.Mount the disk.
DISKPART>online diskList all the volumes in the disk.
DISKPART>list volumeSelect the new volume.
DISKPART>select volumeVOLUME_NUMBERReplace
VOLUME_NUMBERwith the number of the volume toconfigure as read and write.Clear the read-only flag.
DISKPART>attr volume clear readonly hidden nodefaultdriveletter shadowcopyExit the
diskparttool.DISKPART>exitIf the disk is a boot disk for another VM, sync the boot disk fileswith the new disk signature.
PS C:\>bcdbootDRIVE_LETTERWindows /sDRIVE_LETTERReplace
DRIVE_LETTERwith the drive letter for the volumethat you want to sync. For example,FforF:\.
Create a snapshot without using VSS
In some situations, you might want to create snapshots of disks that areattached to Windows VMs without using VSS.
To create a disk snapshot on a Windows VM without using VSS, do the following:
Prepare your system for a clean snapshot
Before you create a disk snapshot, make sure that you are taking asnapshot that is consistent with the state that you want for the disk. Ifyou take a snapshot of your disk in an "unclean" state, it may forcea disk check and possibly lead to data loss. Consider syncing and unmountingyour file system.
Sync the file system
If unmounting your disk is not an option, such as in scenarios wherean application might be writing data to the disk, you can sync your file systemto flush the disk buffers. To sync your file system:
- Sign in to your Windows VM.
- Download and install theSync tool from Microsoft.
- Stop your applications from writing to the disk.
- Open an elevated command prompt window.
In the command line window, run:
PS C:\>syncDRIVE_LETTERReplace
DRIVE_LETTERwith the drive letter for the volumethat you want to sync. For example,FforF:\.
Unmount the disk
Sign in to your Windows VM.
Open a PowerShell command prompt and run the
diskparttool.PS C:\>diskpartIdentify the disk that you want to unmount and snapshot.
DISKPART>list diskNext, select the disk using the disk number that you just found.
DISKPART>select diskDISK_NUMBERReplace
DISK_NUMBERwith the number of the disk that youwant to remount.Unmount the disk.
DISKPART>offline disk
Create a snapshot
- If your disk is located in a single zone (zonal Persistent Disk orHyperdisk), follow the steps inCreate a snapshot of a zonal Persistent Disk volume.
- Alternatively, if your Persistent Disk is located in a multiple zones,follow the steps inCreate a snapshot of a regional Persistent Disk volume.
Remount your disk
Sign in to your Windows VM.
Open a PowerShell command prompt and run the
diskparttool.PS C:\>diskpartIdentify the disk that you want to mount.
DISKPART>list diskUse the
select diskcommand to select the disk.DISKPART>select diskDISK_NUMBERReplace
DISK_NUMBERwith the number of the disk that youwant to mount.Mount the disk.
DISKPART>online disk
What's next
- If you took a snapshot of a boot disk, you cancreate a VM from a snapshot.
- To learn how to configure Windows Server so that you can use it to createcustomized Windows Server images for your VMs or instance templates,readCreate custom Windows Server images.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.