Enabling Application-Consistent Backups for Google Cloud Platform

You can use application-consistent backups to protect the Linux instances in your Google Cloud Platform (GCP) environment. Application-consistent backups quiesce or pause the state of running processes on a computer, especially those that might modify information stored on disk during a backup. Quiescing the operating system and file system helps to guarantee a consistent and usable backup that includes pending transactions.

To achieve application-consistent backups in your GCP environment, you must first prepare your guest environment by using pre-process script files and post-process script files. Pre-process script files and post-process script files are batch files or shell scripts that you can run before or after certain job phases for operations such as:

  • Quiescing applications or operating system processes running on the instance

  • Syncing the file system

Both pre-process script files and post-process script files must be copied to all Linux instances that contain the disks you want to protect with application-consistency.

Note

Currently for GCP, you cannot run application-consistent backups for Windows VMs.

Considerations

  • Application consistency is guaranteed only by the behavior of your custom pre-process and post-process scripts, not by the snapshot operation itself.

  • For application-consistent backups to work on instances that have been converted from VMware to GCP, you must install Google Guest Agent services.

Creating the Script Files

Use the following steps to create the pre-process script files and post-process script files for your GCP environment.

Before You Begin

  • Update all Linux instances in your GCP environment to ensure that you are running the most recent software versions.

  • If the /etc/google/snapshots/ path does not exist, you must create it.

  • You can use the gcloud command-line tool or Compute Engine API to create your script files. Download the most recent version of either tool.

    For more information, go to:

Procedure

  1. Access a Linux instance in your GCP environment.

  2. Create the pre-process script file with the name pre.sh in the following directory: /etc/google/snapshots/.

    The full path of your pre-process script file must be /etc/google/snapshots/pre.sh.

    Note

    Verify that pre.sh has execute permissions.

  3. Add the parameters for the operations that should occur before the application-consistent snapshot operation starts.

    You can run the pre-process scripts on all disks on the instance or only on a specific disk on the instance.

    For example:

    To quiesce the file system on all the disks on the instance before the backup starts, use the following script:

    #!/bin/bash fsfreeze -f [example-disk-location]

    To quiesce the file system only on disk1 before the backup starts, use the following script:

    #!/bin/bash if [ $1 == "1/0" ] then fsfreeze -f [example-disk-location] fi

    Note: You can update the disk numbers as required.

  4. Create the post-process script file with the name post.sh in the following directory: /etc/google/snapshots/.

    The full path of your post-process script file must be /etc/google/snapshots/post.sh.

    Note

    Verify that post.sh has execute permissions.

  5. Add the parameters for the operations that should occur after the application-consistent snapshot operation completes.

    You can run the post-process scripts on all disks on the instance or only on a specific disk on the instance.

    For example:

    To unquiesce the file system on all the disks on the instance after the backup completes, use the following script:

    #!/bin/bash fsfreeze -u [example-disk-location]

    To unquiesce the file system only on disk1 after the backup completes, use the following script:

    #!/bin/bash if [ $1 == "1/0" ] then fsfreeze -u [example-disk-location] fi

    Note: You can update the disk numbers as required.

  6. Review the pre-process script files and post-process script files that are available to use with GCP command line tool or Compute Engine API: Pre-Process and Post-Process Scripts for Google Cloud Platform.

  7. Copy the scripts to every instance on which you want to enable Linux application-consistent snapshots.

    You can use the gcloud compute scp command to copy the scripts from your local workstation to a directory on a Linux instance.

    gcloud compute scp local-pre-script-path local-post-script-path instance-name:remote-dir

    Replace the values for the parameters according to the descriptions in the following table:

    Parameter

    Description

    local-pre-script-path

    The path to the pre-process script on the Linux instance

    local-post-script-path

    The path to the post-process script on the Linux instance

    instance-name

    The name of the instance

    remote-dir

    The path to the target directory on the instance. For example, /root/.

Executing the Script Files

Use the following steps to execute the pre-process script files and post-process script files for your GCP environment.

Procedure

  1. On the guest instance, open or create the configuration file: /etc/default/instance_configs.cfg.

  2. To the file, add the following section replacing the values for the parameters according to the descriptions in the following table.

    [Snapshots] enabled = true, timeout_in_seconds = n

Parameter

Value

Default

Description

enabled

true or false

false

Whether the application consistent snapshot feature is enabled.

timeout_in_seconds

integer (0 - 300)

60

The number of seconds the pre-process or post-process script can take to complete before a timeout error.

Note: The maximum number of seconds the snapshot operation can take to complete before a timeout error is 300 seconds per disk. (This is not configurable.)

  1. Save your configuration settings:
sudo systemctl restart google-guest-agent.service.

What to Do Next

Enable File system and application-consistent backups in the Command Center. For more information, see Editing VM Group Settings for Google Cloud Platform.

Loading...