Add backup / restore admin commands

This commit is contained in:
Ben Meadors
2025-03-03 06:48:06 -06:00
parent faa8064ccc
commit 4bf61d4c98
2 changed files with 55 additions and 1 deletions

View File

@@ -462,6 +462,21 @@ def onConnected(interface):
waitForAckNak = True
interface.getNode(args.dest, False, **getNode_kwargs).removeFavorite(args.remove_favorite_node)
if args.backup_prefs:
closeNow = True
waitForAckNak = True
interface.getNode(args.dest, False, **getNode_kwargs).re(args.backup_preferences)
if args.restore_prefs:
closeNow = True
waitForAckNak = True
interface.getNode(args.dest, False, **getNode_kwargs).re(args.backup_preferences)
if args.remove_backup_prefs:
closeNow = True
waitForAckNak = True
interface.getNode(args.dest, False, **getNode_kwargs).re(args.remove_backup_preferences)
if args.set_ignored_node:
closeNow = True
waitForAckNak = True

View File

@@ -707,8 +707,47 @@ class Node:
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)
def backupPreferences(self, location: int = 0):
"""Tell the node to backup preferences to flash."""
self.ensureSessionKey()
p = admin_pb2.AdminMessage()
p.backup_preferences = location
if self == self.iface.localNode:
onResponse = None
else:
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)
def restorePreferences(self, location: int = 0):
"""Tell the node to restore preferences from backup."""
self.ensureSessionKey()
p = admin_pb2.AdminMessage()
p.restore_preferences = location
if self == self.iface.localNode:
onResponse = None
else:
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)
def removePreferencesBackups(self, location: int = 0):
"""Tell the node to remove backup preferences from the filesystem."""
self.ensureSessionKey()
p = admin_pb2.AdminMessage()
p.remove_backup_preferences = location
if self == self.iface.localNode:
onResponse = None
else:
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)
def removeFavorite(self, nodeId: Union[int, str]):
"""Tell the node to set the specified node ID to be un-favorited on the NodeDB on the device"""
"""Tell the node to set the specified node ID to be un-favorited on the NodeDB on the device."""
self.ensureSessionKey()
if isinstance(nodeId, str):
if nodeId.startswith("!"):