Creating a Windows Persistent Disk Snapshot

This page explains how to create snapshots of a Windows persistent disk. To learn more about persistent disks, read the Persistent Disk documentation.

Compute Engine uses differential snapshots, which allow for better performance and lower storage charges for users. If you just want to configure your operating system and apply those same configurations to other instances, create images instead.

Create a Windows VSS snapshot

For most situations, taking snapshots with the Volume Shadow Copy Service (VSS) is the most simple way to make snapshots of persistent disks that are attached to Windows instances. You can create VSS snapshots without having to stop the instance or detatch the persistent disk. VSS snapshots work both on boot persistent disks and on secondary persistent disks.

VSS snapshots are the same price as normal persistent disk snapshots, and charge only for the total size of the snapshot.

Restrictions

  • VSS snapshots work only on Windows instances with image version v20160810 and newer. For instances with older images, create a regular snapshot.
  • The persistent disk must use an NTFS, exFAT, or ReFS file system.

Create the snapshot

Console


  1. Go to the Create a new snapshot page.
  2. Enter a snapshot name and select an existing disk from which you want to make a snapshot.
  3. Check the Enable VSS option to specify that this snapshot should use the Volume Shadow Copy Service.
  4. Click Create to create the snapshot.

gcloud


To create your snapshot, use the gcloud compute disks snapshot command with the --guest-flush flag to indicate that you want to create a VSS snapshot:

gcloud compute disks snapshot [DISK_NAME] --guest-flush

gcloud waits until the operation returns a status of READY or FAILED, or reaches the maximum timeout and returns the last known details of the snapshot.

API


Make a POST request to the [createSnapshot](/compute/docs/reference/latest/disks/createSnapshot) method and include the ?guestFlush=true parameter to indicate that you want to create a VSS snapshot:

POST  https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/disks/[DISK_NAME]/createSnapshot?guestFlush=true

where:

  • [PROJECT_ID] is your project ID.
  • [ZONE] is the zone where your instance and new disk are located.
  • [DISK_NAME] is the name of the new disk.

You now have a persistent disk snapshot that you can use to create new persistent disks.

Create a regular snapshot

In some situations, you might want to use the standard snapshot system to create snapshots of disks that are attached to Windows instances.

To create a snapshot:

  1. Unmount the filesystem
  2. Create a snapshot
  3. Remount your disk

Before you begin

Unmounting the filesystem

Before you create a persistent disk snapshot, make sure that you are taking a snapshot that is consistent with the desired state of your persistent disk. If you take a snapshot of your persistent disk in an "unclean" state, it may force a disk check and possibly lead to data loss. Follow these instructions to clear your disk buffers for your Windows instance.

  1. Log in to your Windows instance.
  2. Open a command prompt and type diskpart.
  3. Get the disk number:

    list disk
    
  4. Next, select the disk using the disk number you just found:

    select disk [DISK_NUMBER]
    
  5. Finally, unmount the disk:

    offline disk
    

If unmounting your persistent disk is not an option, such as in scenarios where an application might be writing data to the disk, you can sync your file system to flush the disk buffers. To sync your file system:

  1. Log in to your Windows instance.
  2. Download and install the Sync tool.
  3. Stop your applications from writing to your persistent disk.
  4. Run a command prompt as Administrator by right-clicking on the command prompt icon and selecting Run as administrator.
  5. In the command line terminal, run:

    sync [DRIVE_LETTER]
    

Creating a snapshot

Console


  1. Go to the Create a new snapshot page in the Cloud Platform Console.

    Create a new snapshot

  2. If prompted, select a Cloud Platform Console project.
  3. Provide a name and description for the snapshot, select a source disk, and select an encryption option.
  4. Click Create to create the snapshot.

gcloud


Use the gcloud compute disks snapshot command:

gcloud compute disks snapshot [DISK_NAME]

where [DISK_NAME] is the name of the disk you want to make a snapshot of.

gcloud waits until the operation returns a status of READY or FAILED, or reaches the maximum timeout and returns the last known details of the snapshot.

API


Make a POST request to the createSnapshot method:

    POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/us-central1-f/disks/[DISK_NAME]/createSnapshot
  • [PROJECT_ID] is the project ID for this request.
  • [DISK_NAME] is the name of the disk from which to create a snapshot.

Remounting your disk

  1. On your Windows instance, use the same diskpart command-line tool to re-select the disk:

    select disk [DISK_NUMBER]
    
  2. Remount the disk:

    online disk
    

What's next

Send feedback about...

Compute Engine Documentation