This page explains how to create and manage a backup plan for vaulted backups. For a description of what backup plans are and how they are used, see Backup plans in the Google Cloud console.
Before you begin
To get the permissions that
you need to create and manage a backup plan,
ask your administrator to grant you the
Backup and DR User V2 (roles/backupdr.userv2) IAM role on your backup vault project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to create and manage a backup plan. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to create and manage a backup plan:
-
backupdr.backupPlans.create -
backupdr.backupPlans.list -
backupdr.backupPlans.get -
backupdr.backupPlans.delete -
backupdr.backupVaults.associate
You might also be able to get these permissions with custom roles or other predefined roles.
For guidance on granting a user the ability to apply backup plans in a given project (without the ability to create backup plans), see IAM roles and permissions for the backup user.
Create a backup plan
Use the following instructions to create a backup plan for vaulted backups:
Console
- In the Google Cloud console, go to the Backup plans page in the Backup and DR section.
- Click Create Backup plan.
- For Resource Type, select your target resource.
- For Identity, provide a unique Name and an optional Description.
- For Location, select the Region where the plan is active.
- For Destination, select the Backup vault that stores the data.
- To configure backup rules, do the following:
- Click Add rule.
- Set the Recurrence.
- Set the Backup window.
- Set the Retention period.
- For On-Demand Retention, set the Maximum custom on-demand retention value. If unspecified, the vault's minimum enforced retention plus 30 days is used as the default limit.
- For databases, toggle Database Logs to enable transaction log protection.
- Click Create.
A backup plan and its linked backup vault must reside in the same project.
gcloud
Create a backup plan with a backup rule for a Compute Engine instance.
gcloud backup-dr backup-plans create BACKUP_PLAN_NAME \ --location=REGION \ --resource-type=RESOURCE_TYPE \ --project=PROJECT_ID \ --backup-vault=BACKUPVAULT_NAME \ --backup-rule=rule-id=RULE_NAME,recurrence=RECURRENCE,hourly-frequency=HOURS,time-zone=TIME_ZONE,backup-window-start=START_TIME,backup-window-end=END_TIME,retention-days=BACKUP_RETENTION --max-custom-on-demand-retention-days=MAX_ONDEMAND_RETENTIONReplace the following:
BACKUP_PLAN_NAME: the name of the backup plan.REGION: the Google Cloud region where you want to create the backup plan.RESOURCE_TYPE: the resource type to be protected by the backup plan. Values are:compute.googleapis.com/Instancecompute.googleapis.com/Disksql.googleapis.com/Instancealloydb.googleapis.com/Clusterfile.googleapis.com/Instance
PROJECT_ID: the name of the project where the backup vault resides.BACKUPVAULT_NAME: the name of the backup vault that you want to use for backup storage.RULE_NAME: the name of the backup rule.RECURRENCE: the frequency at which backups to be created. It can be hourly, daily, weekly, monthly, or yearly.HOURS: the frequency of the hourly backups. Specify this value only if you set the recurrence to hourly. The minimum hourly is always set to six hours.TIME_ZONE: the time zone for the backup plan, such as UTC. Use the IANA time zone format to include the timezone for the backup plan.START_TIME: the start time is the hour of the day in a 24 hour format. The start time must be before the end time and is inclusive for the backup window.END_TIME: the end time is the hour of the day in a 24 hour format. The end time must be after the start time and is exclusive for the backup window.BACKUP_RETENTION: the retention period of the backup. Note that the backup retention period must be equal to or greater than the backup vault enforced minimum retention period.MAX_ONDEMAND_RETENTION: The maximum allowed custom retention period (in days) for on-demand backups created using this backup plan.
Create a backup plan with no backup rule for a Compute Engine instance.
gcloud backup-dr backup-plans create BACKUP_PLAN_NAME \ --location=REGION \ --resource-type=RESOURCE_TYPE \ --project=PROJECT_ID \ --backup-vault=BACKUPVAULT_NAME \ --max-custom-on-demand-retention-days=MAX_ONDEMAND_RETENTIONExamples of assigning a backup plan:
Example: Back up a Compute Engine instance every six hours and store the backups for 11 days.
gcloud backup-dr backup-plans create bp-hourly \ --project=test-project --location=us-central1 \ --resource-type=compute.googleapis.com/Instance \ --backup-vault=test-bv \ --backup-rule=rule-id=rule-hourly,recurrence=HOURLY,hourly-frequency=6,backup-window-start=5,backup-window-end=12,retention-days=11Example: Back up disks daily between 5 AM and 12 PM and store the backups for 12 days.
gcloud backup-dr backup-plans create bp-daily \ --project=test-project --location=us-central1 \ --resource-type=compute.googleapis.com/Disk \ --backup-vault=test-bv \ --backup-rule=rule-id=rule-daily,recurrence=DAILY,backup-window-start=5,backup-window-end=12,retention-days=12Example: Back up a Compute Engine instance on Monday and Wednesday between 5 AM and 12 PM and store the backups for 13 days.
gcloud backup-dr backup-plans create bp-weekly \ --project=test-project --location=us-central1 \ --resource-type=compute.googleapis.com/Instance \ --backup-vault=test-bv \ --backup-rule=rule-id=rule-weekly,recurrence=WEEKLY,days-of-week='MON WED',backup-window-start=5,backup-window-end=12,retention-days=13Example: Back up disks on 1st and 15th of every month between 5 AM and 12 PM and store the backups for 14 days.
gcloud backup-dr backup-plans create bp-monthly \ --project=test-project --location=us-central1 \ --resource-type=compute.googleapis.com/Disk \ --backup-vault=test-bv \ --backup-rule=rule-id=rule-monthly,recurrence=MONTHLY,days-of-month='1 15',backup-window-start=5,backup-window-end=12,retention-days=14Example: Back up a Compute Engine instance on the 10th, 20th, 30th of March, June, September, December of every year, and store the backups for 16 days.
gcloud backup-dr backup-plans create bp-yearly \ --project=test-project --location=us-central1 \ --resource-type=compute.googleapis.com/Instance \ --backup-vault=test-bv \ --backup-rule=rule-id=rule-yearly,recurrence=YEARLY,months='MAR JUN SEP DEC',days-of-month='10 20 30',backup-window-start=5,backup-window-end=12,retention-days=16
Terraform
You can use a Terraform resource to create a backup plan with an hourly, daily, weekly, monthly, or yearly backup frequency.
List backup plans
Use the following instructions to list backup plans.
Console
In the Google Cloud console, go to the Backup plans page.
The Backup plan page lists all of the backup plans in your project.
gcloud
List the backup plans.
gcloud backup-dr backup-plans list \ --location=LOCATION \ --project=PROJECT_IDReplace the following:
LOCATION: the location of the backup plans.PROJECT_ID: the name of the project where the backup plans are created.
View backup plan details
Use the following instructions to view backup plan details.
Console
In the Google Cloud console, go to the Backup plans page.
In the list of backup plans, click the name of the of the backup plan you want to view.
The backup plan details displays the following information:
- Resource type
- Backup plan details
- Backup vault name
- Backup storage location
- Backup retention period
gcloud
View the backup plan details.
gcloud backup-dr backup-plans describe BACKUP_PLAN_NAME \ --location=LOCATION \ --project=PROJECT_IDReplace the following:
BACKUP_PLAN_NAME: the name of the backup plan.LOCATION: the location of the backup plan.PROJECT_ID: the name of the project where the backup plan is created.
Delete a backup plan
A backup plan cannot be deleted if you are using it to protect a resource. To delete a backup plan, first remove the backup plan from the resource and then delete it.
When you delete a backup plan:
- Backups created while the plan was applied are not affected. Backups expire according to their retention periods and can be accessed until then.
- Any automations that reference the plan will no longer work.
Use the following instructions to delete a backup plan.
Console
In the Google Cloud console, go to the Backup plans page.
Click the backup plan you want to delete.
Click Delete.
In the overlay window that appears, confirm you want to delete the backup plan and its contents.
Click Delete.
gcloud
Delete a backup plan.
gcloud backup-dr backup-plans delete BACKUP_PLAN_NAME \ --location=LOCATION \ --project=PROJECT_IDReplace the following:
BACKUP_PLAN_NAME: the name of the backup plan that you want to delete.LOCATION: the location of the backup plan.PROJECT_ID: the name of the project where the backup plan is created.