CREATE BACKUP SET
statementpartialReplication, failover & backupBusiness Critical+Creates a backup set for one of the following: - A table, including a dynamic table or a Snowflake Storage for Apache Iceberg™ table - A schema - A database Once the backup set exists, you can add a new backup (backup) to the backup set at any time by running an ALTER BACKUP SET command. Snowflake also adds backups to the backup set automatically, if you defined a schedule in a backup policy and associated that backup policy with the backup set. Each backup set represents a set of backups for a specific table, or the objects in a specific schema, or the objects in a specific database. That way, you can make your backups very granular or very comprehensive. And the backups for each table, schema, or database can have their own independent schedules. For the kinds of objects that are included in schema backups and database backups, see Backup objects. This command supports the following variants: - CREATE OR ALTER BACKUP SET: Creates a backup set if it doesn’t exist or alters an existing backup set. Backups are available for all Snowflake editions. Backups with retention lock and backups with legal holds are available for Business Critical Edition (or higher). To inquire about upgrading, please contact Snowflake Support.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] BACKUP SET [ IF NOT EXISTS ] <name>
FOR [ DYNAMIC ] [ ICEBERG ] TABLE <table_name>
[ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
CREATE [ OR REPLACE ] BACKUP SET [ IF NOT EXISTS ] <name>
FOR SCHEMA <schema_name>
[ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
CREATE [ OR REPLACE ] BACKUP SET [ IF NOT EXISTS ] <name>
FOR DATABASE <database_name>
[ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
For an existing backup set, you can update the COMMENT and attach a WITH BACKUP POLICY if one isn’t already set. The FOR target can’t be changed, and an attached backup policy can’t be replaced or removed.
CREATE OR ALTER BACKUP SET <name>
FOR [ DYNAMIC ] [ ICEBERG ] TABLE <table_name>
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
For an existing backup set, you can update the COMMENT and attach a WITH BACKUP POLICY if one isn’t already set. The FOR target can’t be changed, and an attached backup policy can’t be replaced or removed.
CREATE OR ALTER BACKUP SET <name>
FOR SCHEMA <schema_name>
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
For an existing backup set, you can update the COMMENT and attach a WITH BACKUP POLICY if one isn’t already set. The FOR target can’t be changed, and an attached backup policy can’t be replaced or removed.
CREATE OR ALTER BACKUP SET <name>
FOR DATABASE <database_name>
[ WITH BACKUP POLICY <policy_name> ]
[ COMMENT = <string> ]
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Identifier for the backup set; must be unique for your account. 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. |
FOR [ DYNAMIC ] [ ICEBERG ] TABLE table_name | required | Specifies the name of a table. The backup set represents backups of that single table. For a standard table, use FOR TABLE. For a dynamic table, use FOR DYNAMIC TABLE. For a Snowflake Storage for Apache Iceberg™ table, use FOR ICEBERG TABLE. For a dynamic Iceberg table that uses Snowflake Storage, use FOR DYNAMIC ICEBERG TABLE. If the schema uses DEFAULT_METADATA_WRITE_FORMAT = ICEBERG, Snowflake can promote FOR TABLE or FOR DYNAMIC TABLE to the corresponding Iceberg variant. Prefer the explicit Iceberg syntax for Iceberg tables. |
FOR SCHEMA schema_name | required | Specifies the name of the schema. In that case, the backup set represents backups of all the tables and other objects in a specific schema. |
FOR DATABASE database_name | required | Specifies the name of the database. In that case, the backup set represents backups of all the tables, schemas, and other objects in a specific database. |
OR REPLACE | optional | If a backup set with this name already exists, delete it and create a new one. If the backup set can’t be deleted because of backup policy rules for retention locks, legal holds, and expiry times, the command fails. This clause is mutually exclusive with IF NOT EXISTS. |
IF NOT EXISTS | optional | Creates the backup set only if there isn’t a backup set with the same name. If a backup set already exists, the command returns a success message even though it has no effect. This clause is mutually exclusive with OR REPLACE. |
TAG ( tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] ) | optional | 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. |
WITH BACKUP POLICY policy_name | optional | Specifies the name of the backup policy for the set. The backup policy defines properties of the backup set such as the schedule for backups, the retention period for each backup, and whether to prevent backups from being removed before the end of the retention period. If you omit this parameter from the CREATE BACKUP SET command, you can apply a policy later with the ALTER BACKUP SET command. Important Applying a backup policy with a retention lock to a backup set is irreversible. Due to the strong guarantees that are needed for regulatory compliance, after you put a retention lock on a backup set, you can’t revoke the lock. Snowflake support also can’t revoke such a retention lock. Plan carefully before you set a retention lock on a backup set with a long expiration period, to avoid unexpected storage charges for undeletable backup sets, and the schemas and databases that contain them. If a Snowflake organization is deleted, the organization is no longer a Snowflake customer. In this case, Snowflake deletes all backups, including those with retention locks. Deleting a Snowflake organization requires the involvement of Snowflake support. It isn’t something that an administrator can do by accident. |
COMMENT = 'string_literal' | optional | Specifies a comment for the backup set. Default: No value |
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.
- You can’t create a backup set for a transient table, including a dynamic transient table. The statement fails with an error. For more information, see Backups: Transient tables are no longer supported.
- Important
- If the backup policy has a retention lock applied to it, and there are any unexpired backups in the backup set, then you can’t delete the backup set. In that case, you must wait for all the backups in the set to expire. This restriction applies even to privileged roles such as ACCOUNTADMIN, and to Snowflake support. For that reason, be careful when specifying retention lock and a long expiration period in a backup policy.
- For Iceberg tables and dynamic Iceberg tables, only Snowflake Storage for Apache Iceberg™ tables are supported, and only on Amazon Web Services (AWS). Iceberg tables on customer-managed storage, Iceberg tables that use an external catalog, and transient Iceberg tables aren’t supported.
- The FOR clause must match the object type. For example, use FOR ICEBERG TABLE for an Iceberg table. If you use the wrong clause, the command fails.
- If the schema uses DEFAULT_METADATA_WRITE_FORMAT = ICEBERG, Snowflake can promote FOR TABLE to FOR ICEBERG TABLE, and FOR DYNAMIC TABLE to FOR DYNAMIC ICEBERG TABLE. Prefer the explicit Iceberg keywords in your SQL.
- All limitations of the ALTER BACKUP SET command apply.
- The FOR target can’t be changed.
- A backup policy can be attached if the backup set doesn’t already have one, but an existing backup policy can’t be replaced or removed.
- Tags aren’t supported.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Notes CREATE BACKUP SET | The role used to create a backup set must have this privilege granted on the schema in which the backup set is created. To actually create the backup set also requires the appropriate privilege on the object that’s the subject of the backup set: SELECT for a table backup, or USAGE for a schema backup or database backup. SELECT | The role used to create a backup set for a table must have the SELECT privilege on that table. USAGE | The role used to create a backup set for a schema or database must have the USAGE privilege on that schema or database. APPLY | The role used to apply a backup policy on a backup set must have this privilege on the backup policy. APPLY BACKUP RETENTION LOCK | The role used to apply a backup policy with retention lock on a backup set must have this privilege on the account. OWNERSHIP | Required to execute a CREATE OR ALTER BACKUP SET statement for an existing backup set. These privileges are required on the currently active primary role, not a secondary role. 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.
Known gaps
- IF NOT EXISTS, WITH, TAG, WITH BACKUP POLICY, OR REPLACE, COMMENT are not exercised by any test