Snapshots

A snap’s system and user data can be excluded from snapshots by specifying exclusion patterns in an optional metadata file called snapshots.yaml. Such exclusions can be used to control snapshot content and size.

Important

The snap restore command replaces a snap’s system and user data with the snapshot content, meaning that excluded files and directories will be lost.

snapshots.yaml syntax

The snapshots.yaml configuration file starts with the exclude keyword followed by a list of shell-style wildcard patterns to indicate which files or directories to exclude.

These wildcard patterns must start with a system or user data environment variable. Only the asterisk wildcard is supported.

snapshots.yaml
exclude:
  - <environment-variable>/<path>
  ...
  - <environment-variable>/<path>

Including snapshots.yaml in a snap

The snapshots.yaml file must be located within a snap’s meta directory. This is typically done by creating a part that uses either the dump plugin or a build step override to copy snapshots.yaml from another directory.