Backing up and restoring file shares

This page describes how to back up and restore Basic HDD and Basic SSD tier Filestore instances. To learn more about backups, common use cases, and best practices, see Backups.

Before you begin

  1. Update and install gcloud components:

    gcloud components update &&
    gcloud components install alpha beta
    
  2. Ensure that the account you are using has either the Cloud Filestore Editor role, or the Project Owner or Project Editor basic role. For more information about roles and permissions for Filestore, see Access Control.

Backing up a file share

You can create a backup of a file share using one of the following methods:

Console

  1. Go to the Filestore instances page
  2. Click on the Filestore instance that you want to create a backup of.
  3. Click Create backup.
  4. For Backup ID, type a name for the backup.
  5. For Region, select the Google Cloud region where you want the backup to be located.
  6. Optional: To add a description or labels to the backup, click Show advanced options.
  7. Click Create.

gcloud

Run the following command in a terminal window on your local machine:

gcloud beta filestore backups create backup-name \
    --instance=instance-name \
    --file-share=file-share-name \
    --instance-zone=zone \
    --region=backup-location

where:

  • backup-name is the name you want to give the backup.
  • instance-name is the name of the Filestore instance to backup.
  • file-share-name is the name of the file share on the Filestore instance.
  • zone is the zone where the Filestore instance is located.
  • backup-location is the region where the backup is stored. If region is unspecified, the backup is created in the same region as the Filestore instance.

Example

The following command creates a backup of file share vol1 on the Filestore instance nfs-server, which is located in zone us-central1-c. The backup is named mybackup and is located in region asia-east2.

gcloud beta filestore backups create mybackup \
    --instance=nfs-server \
    --file-share=vol1 \
    --instance-zone=us-central1-c \
    --region=asia-east2

Listing, viewing, updating, and deleting backups

Filestore backups can be listed, viewed, updated, and deleted.

Console

  • To view a list of all backups in your current project:

    Go to the Filestore backups page

  • To see details about a backup, click the backup ID .

  • To delete a backup:

    1. Click the backup ID of the backup you want to delete.
    2. Click Delete.
    3. When prompted, type the backup ID.
    4. Click Delete.

gcloud

Listing all backups in your current project

To view a list of all of the backups for your current project, run the following command:

gcloud beta filestore backups list

Viewing information about a backup

To view information about a backup, run the following command:

gcloud beta filestore describe backup-name \
    --region=backup-location

Where:

  • backup-name is the name of the backup whose information you want to view.
  • backup-location is the region the backup is stored.

Updating a backup

To update a backup, run the following command:

gcloud beta filestore backups update backup-name \
  --region=backup-location \
  --description="new-description" \
  --update-labels=key=value,...

Where:

  • backup-name is the name of the backup whose information you want to view.
  • backup-location is the region the backup is stored.
  • new-description is the description of the backup.
  • key=value,... is a list of KEY=VALUE pairs you want to update. If a label exists, its value will be updated, otherwise a new label is created.

Deleting a backup

To delete a backup, run the following command:

gcloud beta filestore backups delete backup-name \
  --region backup-location

Where:

  • backup-name is the name of the backup whose information you want to view.
  • backup-location is the region the backup is stored.

Restoring a file share

File shares can be restored from a backup to either a new Filestore instance or to a file share of an existing instance. You must re-mount the file share after it is restored from a backup. All outstanding file locks are revoked upon successful restoration.

Restoring to an existing instance

When restoring a backup to an existing file share, the capacity of the file share is automatically updated to the capacity of the backup, or the minimum capacity allowed for the instance tier, whichever is greater.

In the event that the restore fails, the file share state remains unchanged.

Console

  1. Go to the Filestore instances page
  2. Click the instance ID of the instance you want to restore a backup to.
  3. Click Restore from backup.
  4. For Source backup, select the backup that you want to restore from.
  5. Click Restore and a confirmation dialog will appear.
  6. Enter Restore in the input field and click Restore.

gcloud

To restore a Filestore file share to an existing instance, run the following command:

gcloud beta filestore instances restore instance-name \
    --source-backup=backup-name \
    --source-backup-region=backup-location \
    --file-share=file-share-name \
    --zone=instance-location

Where:

  • instance-name is the name of the existing Filestore instance the to restore the file share to.
  • backup-name is the name of the backup to restore from.
  • backup-location is the region that the backup is located.
  • file-share-name is the name of the file share to restore to.
  • instance-location is the zone that the Filestore instance is located.

Example

The following command restores mybackup, which is located in region asia- east2, to file share vol1 on Filestore instance myinstance, which is located in zone us-central1-c:

gcloud beta filestore instances restore myinstance \
    --source-backup=mybackup \
    --source-backup-region=asia-east2  \
    --file-share=vol1 \
    --zone=us-central1-c

Restoring to a new instance

When a backup is restored to a new Filestore instance, the capacity of the new file share needs to be equal to or larger than the capacity of the backup.

You can also choose an instance tier that is different from the original.

Console

  1. In the Cloud Console, go to the Filestore instances page.

    Go to the Filestore instances page

  2. Click Backups.

  3. Click the name of the backup you want to restore from.

  4. Click Create instance from backup.

  5. Configure the new instance by following the instructions on the page. For details, see Creating instances.

  6. Click Create.

gcloud

To restore a Filestore file share to a new instance, run the following command:

gcloud beta filestore instances create instance-name \
    --zone=zone \
    --file-share=name=file-share-name,capacity=file-share-capacity,source-backup=source-backup-name,source-backup-region=source-backup-location \
    --network=name=vpc-network,reserved-ip-range=reserved-ip-address

Where:

  • instance-name is the name you want to give to the new Filestore instance.
  • zone is the zone where the Filestore instance resides.
  • file-share-name is the name you specify for the NFS file share that is served from the instance.
  • file-share-capacity is the capacity you want for the file share.
  • source-backup-name is the name of the backup to restore from.
  • source-backup-location is the region that the backup is located.
  • vpc-network is the name of the VPC network you want the instance to use.
  • reserved-ip-address is the IP address range for the Filestore instance.

Example

The following command creates a new Filestore instance myinstance-restored located in zone us-central1-c on network default. Backup mybackup located in region asia-east2 is restored on file share vol1 of myinstance- restored with a 2TB capacity:

gcloud beta filestore instances create myinstance-restored \
    --zone=us-central1-c \
    --network=name=default \
    --file-share=name=vol1,capacity=2TB,source-backup=mybackup,source-backup-region=asia-east2

What's next