Module to manage filesystem snapshots with snapper
New in version 2016.11.0.
Duncan Mac-Vicar P. <dmacvicar@suse.de>
Pablo Suárez Hernández <psuarezhernandez@suse.de>
dbus
Python module.
snapper
http://snapper.io, available in most distros
new
Linux
Returns the files changed between two snapshots
Configuration name.
first snapshot ID to compare. Default is last snapshot
last snapshot ID to compare. Default is 0 (current state)
CLI Example:
salt '*' snapper.changed_files
salt '*' snapper.changed_files num_pre=19 num_post=20
Creates a snapshot marked as baseline
Tag name for the baseline
Configuration name.
CLI Example:
salt '*' snapper.create_baseline
salt '*' snapper.create_baseline my_custom_baseline
Creates a new Snapper configuration
Name of the new Snapper configuration.
Path to the related subvolume.
Filesystem type of the subvolume.
Configuration template to use. (Default: default)
Extra Snapper configuration opts dictionary. It will override the values provided by the given template (if any).
CLI Example:
salt '*' snapper.create_config name=myconfig subvolume=/foo/bar/ fstype=btrfs
salt '*' snapper.create_config name=myconfig subvolume=/foo/bar/ fstype=btrfs template="default"
salt '*' snapper.create_config name=myconfig subvolume=/foo/bar/ fstype=btrfs extra_opts='{"NUMBER_CLEANUP": False}'
Creates an snapshot
Configuration name.
Specifies the type of the new snapshot. Possible values are single, pre and post.
For post snapshots the number of the pre snapshot must be provided.
Description for the snapshot. If not given, the salt job will be used.
Set the cleanup algorithm for the snapshot.
Deletes old snapshots when a certain number of snapshots is reached.
Deletes old snapshots but keeps a number of hourly, daily, weekly, monthly and yearly snapshots.
Deletes pre/post snapshot pairs with empty diffs.
Set userdata for the snapshot (key-value pairs).
Returns the number of the created snapshot.
CLI Example:
salt '*' snapper.create_snapshot
Deletes an snapshot
Configuration name. (Default: root)
List of the snapshots IDs to be deleted.
CLI Example:
salt '*' snapper.delete_snapshot 54
salt '*' snapper.delete_snapshot config=root 54
salt '*' snapper.delete_snapshot config=root snapshots_ids=[54,55,56]
Returns the differences between two snapshots
Configuration name.
if not provided the showing differences between snapshots for all "text" files
first snapshot ID to compare. Default is last snapshot
last snapshot ID to compare. Default is 0 (current state)
CLI Example:
salt '*' snapper.diff
salt '*' snapper.diff filename=/var/log/snapper.log num_pre=19 num_post=20
Returns the changes applied by a jid
The job id to lookup
Configuration name.
CLI Example:
salt '*' snapper.diff_jid jid=20160607130930720112
Retrieves all values from a given configuration
CLI Example:
salt '*' snapper.get_config
Get detailed information about a given snapshot
CLI Example:
salt '*' snapper.get_snapshot 1
List all available configs
CLI Example:
salt '*' snapper.list_configs
List available snapshots
CLI Example:
salt '*' snapper.list_snapshots config=myconfig
Modify attributes of an existing snapshot.
Configuration name. (Default: root)
ID of the snapshot to be modified.
Change the cleanup method of the snapshot. (str)
Change the description of the snapshot. (str)
Change the userdata dictionary of the snapshot. (dict)
CLI Example:
salt '*' snapper.modify_snapshot 54 description="my snapshot description"
salt '*' snapper.modify_snapshot 54 description="my snapshot description"
salt '*' snapper.modify_snapshot 54 userdata='{"foo": "bar"}'
salt '*' snapper.modify_snapshot snapshot_id=54 cleanup="number"
Runs a function from an execution module creating pre and post snapshots and associating the salt job id with those snapshots for easy undo and cleanup.
Salt function to call.
Configuration name. (default: "root")
A description for the snapshots. (default: None)
Data to include in the snapshot metadata. (default: None)
Snapper cleanup algorithm. (default: "number")
args for the function to call. (default: None)
kwargs for the function to call (default: None)
This would run append text to /etc/motd using the file.append module, and will create two snapshots, pre and post with the associated metadata. The jid will be available as salt_jid in the userdata of the snapshot.
You can immediately see the changes
CLI Example:
salt '*' snapper.run file.append args='["/etc/motd", "some text"]'
Set configuration values
CLI Example:
salt '*' snapper.set_config SYNC_ACL=True
Keys are case insensitive as they will be always uppercased to snapper convention. The above example is equivalent to:
salt '*' snapper.set_config sync_acl=True
Returns a comparison between two snapshots
Configuration name.
first snapshot ID to compare. Default is last snapshot
last snapshot ID to compare. Default is 0 (current state)
CLI Example:
salt '*' snapper.status
salt '*' snapper.status num_pre=19 num_post=20
Converts a numeric dbus snapper status into a string
CLI Example:
salt '*' snapper.status_to_string <dbus_status>
Undo all file changes that happened between num_pre and num_post, leaving the files into the state of num_pre.
Warning
If one of the files has changes after num_post, they will be overwritten The snapshots are used to determine the file list, but the current version of the files will be overwritten by the versions in num_pre.
You to undo changes between num_pre and the current version of the files use num_post=0.
CLI Example:
salt '*' snapper.undo
Undo the changes applied by a salt job
The job id to lookup
Configuration name.
CLI Example:
salt '*' snapper.undo_jid jid=20160607130930720112