Skip to content
Marius Bergmann edited this page Sep 20, 2015 · 5 revisions

Script Plugin Ideas

see https://github.com/openSUSE/snapper/issues/28 for the preceding discussion

Use Cases

  • Replace existing grub hooks.
  • Allow scripts to avoid snapshot creation, e.g. when disk is spun-down.
  • Allow other hooks to be run after snapshot creation, like btrfs send'ing a snapshot to another volume.

Proposal

Snapper should read all plugin configuration files from the directory /etc/snapper/plugins. Only files ending in .conf are considered, e.g. /etc/snapper/plugins/grub.conf.

Configuration file syntax

The configuration syntax is inspired by systemd unit definition files and consists of Key = Value pairs without any sectional grouping. These are the possible configuration options:

  • Type: Specifies when the plugin should be run. There are two possible values: action and precondition. Actions are invoked after every snapshot, which has been created. Preconditions are executed before a snapshot is to be created. If the specified command returns any other status code than 0, the snapshot will not be created.

  • Exec: Specifies the command to be run when the plugin hook is invoked.

  • Subvolume: Is as a condition for the plugin's Exec command to be invoked. It matches on a wildcard or regex of the snapshotted subvolume path.

Variable expansion

Variables can be expanded with ${variable-name}.

Possible values for variable-name:

  • snapshot-num: An integer value stating the number of the newly created snapshot (for actions)

Examples

Actions

# /etc/snapper/plugins/grub.conf

Type = action
Exec = /usr/bin/grub-snapper --number=${snapshot-num}
Subvolume = /

Preconditions

# /etc/snapper/plugins/always-works.conf

Type = precondition
Exec = /bin/true
Subvolume = /