consul.api.snapshot module

class consul.api.snapshot.Snapshot(agent)[source]

Bases: object

Saves/restores a full point-in-time snapshot of the Consul server state. Both endpoints require a management-level ACL token – not a granular ACL rule – and are primarily intended for disaster recovery.

save(token=None, dc=None, stale=False)[source]

Saves a snapshot of the current Consul server state as a gzip archive. :param token: a management-level token :param dc: Optional datacenter to target; defaults to the client’s own dc. :param stale: If True, allows any server (not just the leader) to service the request. :return: the raw gzip archive bytes

Parameters:
Return type:

bytes

restore(snapshot, token=None, dc=None)[source]

Restores a previously-saved snapshot. This is a disaster-recovery operation; the target cluster must run the same Consul version as the source cluster. :param snapshot: raw gzip archive bytes, as returned by save() :param token: a management-level token :param dc: Optional datacenter to target; defaults to the client’s own dc. :return: True if the restore succeeded

Parameters:
Return type:

bool