robweber / xbmcbackup

Backup Addon for Kodi
MIT License
112 stars 48 forks source link

Feature Request: Restore Backup from CLI #211

Closed david-morris closed 2 years ago

david-morris commented 2 years ago

Not much point backing up my settings if I can't restore them ;)

Kodi isn't taking input from me, so I'm locked out till I can diagnose the problem.

This is worse than a blocker for my use case; this addon made me feel I could revert a minor version update if I needed to, and I couldn't.

robweber commented 2 years ago

Sorry that you're having this type of issue; however this isn't an improvement that I can, or even want to, make to this addon. The addon is meant to work from within Kodi. That means a working instance of the media center. It uses several Kodi specific Python bindings and even the file read/write commands utilize Kodi IO libraries. This tight integration is what makes the addon cross platform. In short Kodi addons require a working version of Kodi to work.

Even if there was a non-Kodi dependent interface available it's unlikely it would fix your specific problem. The Backup utility doesn't do anything with the Kodi binary files or loaded libraries. It backs up configuration information, mainly XML files, DB flat files and customized settings. You can't use it to roll back to a previous version of Kodi. In your use case it's usefulness would be for completely re-installing Kodi and then using the Restore capability to pull back in your customizations.

If you're using something like LibreELEC there are tools available that may be able to do what you're asking, but they are very OS dependent. Something that works on LibreELEC won't work on Windows. You'll have to hunt down something for your platform.

david-morris commented 2 years ago

Hmm, I was thinking that it would be simple to leave a python script with its own entry point in the sources to the addon. When I install Kodi addons, it brings their sources with them, and my Kodi uses the system-wide install of Python.

Is that not usually the case for Kodi users?

robweber commented 2 years ago

Python may be available but many of the tools addons, any addon, uses are not available generally at the OS level. Kodi has several application specific Python libraries. These libraries are used heavily within individual addons, even for things as simple as loading the addon settings. These libraries are not available for import at the OS level as they are not regular Python packages. Trying to run an addon that uses them at the command line will result in a runtime error. The reason for this is that this is that these libraries are hooks to run C++ under the hood from within Kodi.

A good example is the xbmcvfs module that this addon uses heavily. In Python you'd write:

import xbmcvfs

xbmcvfs.copy('/path/to/file', '/path/to/new/file')

This is valid Python code but won't run on the OS since xbmcvfs will only be imported and run from within the Kodi media center. Looking at the Kodi source code this Python import exposes a C++ class that actually runs the copy function from within the media center. This type of thing is pervasive throughout pretty much all addons, which is why they have to be run from within the Kodi media center.

Dependent libraries are an even bigger issue. This is like if an addon uses a third party library like the requests module. Kodi downloads and injects these at runtime into the classpath. All in all it would be a huge lift to de-couple Kodi specific logic from an addon.

david-morris commented 2 years ago

Wow, that's a lot of infrastructure I wasn't aware of.

Maybe it would be useful to have some sort of README somewhere that explains how to unpack these archives on various platforms, and what tools are needed.

Honestly the whole thing is on me --- I'm educated enough to know that if you have backups and you haven't tested them, you don't have backups.