Table of Contents
Scripting A Backup
If you wish to script this addon using an outside scheduler or script it can be given parameters via the Kodi.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. If mode is "restore", an additional "archive" and "sets" parameters can be given to set the restore point to be used instead of prompting via the GUI. An example of a backup would be:
Python code:
RunScript(script.xbmcbackup,mode=backup)
Backup JSON Request:
{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"backup"}}, "id": 1 }
To script a Restore you need to pass in the archive folder name and the sets within that archive you wish to restore (version 1.5.0 and greater). Be aware you will still get some pop-ups if there are advanced settings or Always Ask To Restore UI settings is turned on.
Restore JSON Request:
{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"restore","archive":"000000000000","sets":"config|database"}}, "id": 1 }
Note the pipe symbol ( | ) between set names.
Check If Backup Running
There is also a windows parameter that can be used to check if Kodi Backup is running within a skin or from another program. It is attached to the home window, an example of using it would be the following:
#kick off the Kodi backup
Kodi.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"backup"}}, "id": 1 }')
#sleep for a few seconds to give it time to kick off
Kodi.sleep(10000)
window = Kodigui.Window(10000)
while (window.getProperty('script.xbmcbackup.running') == 'true'):
#do something here, probably just sleep for a few seconds
Kodi.sleep(5000)
#backup is now done, continue with script