CREATE SNAPSHOT

Creates or replaces a snapshot of a named volume from the specified service instance. The snapshot is created in the current schema.

See also:

ALTER SNAPSHOT, DESCRIBE SNAPSHOT, DROP SNAPSHOT , SHOW SNAPSHOTS

Syntax

CREATE [ OR REPLACE ] SNAPSHOT [ IF NOT EXISTS ] <name>
  FROM SERVICE <service_name>
  VOLUME "<volume_name>"
  INSTANCE <instance_id>
  [ COMMENT = '<string_literal>']
  [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , ... ] ) ]
Copy

Required parameters

name

String that specifies the identifier (that is, name) for the snapshot; must be unique for the schema in which the snapshot is created.

In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive.

For more information, see Identifier requirements.

FROM SERVICE service_name

Specifies the name of the service.

VOLUME "volume_name"

Specifies the name of the volume associated with the service. Snapshots can only be taken for block storage volumes (and not for local, memory, or stage volumes).

Volume names are case-sensitive. Therefore, double quotes should always be used to match the corresponding name in the service specification.

INSTANCE instance_id

Index of the service instance. The service instance index starts at 0 and the range is [0, ...,  MAX_INSTANCES - 1]. You can call the SYSTEM$GET_SERVICE_STATUS function to get the relevant information.

Optional parameters

COMMENT = 'string_literal'

Specifies a comment for the service.

Default: No value

TAG ( tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] )

Specifies the tag name and the tag string value.

The tag value is always a string, and the maximum number of characters for the tag value is 256.

For information about specifying tags in a statement, see Tag quotas for objects and columns.

Access control requirements

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

CREATE SNAPSHOT

Schema

OPERATE

Service

Note that operating on any object in a schema also requires the USAGE privilege on the parent database and schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

  • Regarding metadata:

    Attention

    Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata Fields in Snowflake.

  • CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.

Examples

If you create a service with two instances (the number of containers isn’t relevant) with a volume named “data”, you would create a snapshot of the volume associated with the first instance using the following SQL:

CREATE SNAPSHOT snapshot_0
  FROM SERVICE example_service
  VOLUME "data"
  INSTANCE 0
  COMMENT='new snapshot';
Copy

To create a snapshot of the volume associated with the second service instance, you specify INSTANCE 1 in the preceding SQL.