Snapper agent description


Purpose

The Snapper agent (ag_snapper) is used to access API of libsnapper library from YaST (libsnapper is a library for managing btrfs filesystem snapshots). It is part of YaST2 SCR, the system configuration repository, used to access configuration data on the target system. The general SCR API allows Read() and Write() access to get and change data. However, snapper agent currently provides only Read calls.

Implementation

It is simple wrapper for libsnapper C++ library. The library initialization routines are used to read list of current snapshots and their data.

Each snapshot is described in YCPMap. Snapshot is identified by number. The map also contains the snapshot type (`SINGLE, `PRE, `POST) and the date of snapshot creation. SINGLE and PRE types of snapshot have the description string. The snapshot of PRE type contains number of relevant POST snapshot and vice versa.

Note: The complete development documentation is available in the autodocs/ directory.

Interface for snapper-agent

The interface is implemented as a SCR agent with the usual Read(), Write() and Dir() interface. The path prefix used is The initialization call of Execute (.snapper) must be done before any other calls.

Complete Read paths table

Path Argument Type of Result Result
.snapper.error(none)YCPMap Return information about last error.
Example of result:
	    $[
		"type"		: "config_not_found"
	    ]
	
.snapper.pathYCPMapYCPMap Return the path to directory with given snapshot
Example of argument map:
	    $[
		"num" 	: 1,
	    $]
	    
Example of result:
	    "/snapshots/1/snapshot"
	
.snapper.snapshots(none)YCPList Return list of current snapshot maps.
Example of result:
	  [
	    $[
		"date"		: 1297364138,
		"description"	: "before yast2-users",
		"name"		: "1",
		"num"		: 1,
		"post_num"	: 2,
		"type"		: `PRE
	    ],
	    $[
		"date"		: 1297364204,
		"name"		: "2",
		"num"		: 2,
		"pre_num"	: 1,
		"type"		: `POST
	    ],
	    $[
		"date"		: 1297758106,
		"description"	: "Tuesday",
		"name"		: "3",
		"num"		: 3,
		"type"		: `SINGLE
	    ]
	  ]
	
.snapper.diff_listYCPMapYCPList Returns the list of files modified between given snapshots. Each file is described by YCPMap which contains file path and type of the change. Argument map contains 2 integers, identifying the snapshots.
Example of argument map:
	    $[
		"from" 	: 1,
		"to" 	: 2
	    $]
	    
Example of result:
	  [
	    $[
		"changes"	: "c...",
		"name"		: "/etc/group"
	    ],
	    $[
		"changes"	: "c...",
		"name"		: "/etc/group.YaST2save"
	    ]
	  ]
	
.snapper.diff_indexYCPMapYCPMap Returns the differences between snapnots num1 and num2 as one-level map (mapping each file to its changes).
Example of argument map:
	    $[
		"from" 	: 1,
		"to" 	: 2
	    $]
	    
Example of result:
	  $[
		"/etc/group"		: "c...",
		"/etc/group.YaST2save"	: "c..."
	  ]
	
.snapper.diff_treeYCPMapYCPMap Returns the differences between snapnots num1 and num2 as a tree. Map is recursively describing the filesystem structure; it is used to build Tree widget contents in yast2-snapper UI.
Example of argument map:
	    $[
		"from" 	: 1,
		"to" 	: 2
	    $]
	    
Example of result:
	    $[
		"etc"	: $[
		    "group"		: $[],
		    "group.YaST2save"	: $[],
		    "passwd"		: $[],
		    "passwd.YaST2save"	: $[]
		],
		"var"	: $[
		    "log"		: $[
			"YaST2"		: $[
			    "y2changes"	: $[],
			    "y2log"	: $[]
			],
			"messages"	: $[],
			"snapper.log"	: $[]
		    ]
		]
	    ]
	

Complete Execute paths table

Path Argument Type of Result Result
.snapper(none)YCPBoolean Initializes snapper object. In case of init failure, sets the internal error ID. Use Read (.snapper.error) to get the error info.
.snapper.rollbackYCPMapYCPBoolean Rollback the list of given files from snapshot num1 to num2. If num2 is not present, current system is used as a default. Example of argument map:
	    $[
		"files" : [
		    "/etc/passwd",
		    "/etc/group"
		]
		"from" 	: 1,
	    $]
	    

Jiri Suchomel <jsuchome@suse.cz>