robweber / xbmcbackup

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

[Feature Request] Cloud Storage -> SSH Destination #144

Closed matrix1000 closed 5 years ago

matrix1000 commented 5 years ago

Hi,

I am using Kodi on a raspberry pi.

Is it possible to add a new backupdestination SSH (ssh server, with key authentication) to your addon? I would like to integrate Kodi Backups to my Linuxmaschines.

If you use tar for creating the backups: Example: tar ... | ssh backupserver "cat > ~/Backup-Kodi_2019-01-03_14-51-45.tar.gz"

With this way, there are no write operations on the SD card, which greatly increases its lifetime. :-)

Best regards

robweber commented 5 years ago

This addon uses the xbmcvfs virtual file system as a cross platoform way of providing file system access. This way all the heavy lifting of providing some type of low level file system code is already done via the Kodi app itself.

Looking at the wiki it does appear that there is support for SSH File Transfer Protocol (SFTP) out of the box in Kodi. You should be able to provide a connection string (not sure the format) when setting up the backup location and the addon will write to that location. One caveat to this is that if you're using the ZIP file option the contents of the archive will be written to your local disk first, and then out to the share. this is because the Kodi file system will not write to a zip archive across a network so it has to be done locally and then moved. If you're doing an uncompressed backup the files will write to the location directly.

Here is some info from the wiki on the different file protocols supported. https://kodi.wiki/view/File_sharing#SFTP

matrix1000 commented 5 years ago

Nice idea. If I understand that correctly, you can include a sftp directory to put data on it as if it were a normal folder. But what if the server reboots? Then normally the mountingpoint is blocking the device if its try to use it. Is this here the same point? Would it not be easier to use a command like in my first comment? Therefor the server has not to be mounted all the time.

robweber commented 5 years ago

I guess I'm not sure what will happen if the server were to reboot in the beginning of a file operation. Kodi devs might better be able to shed light on that one, it might depend on the server too. I would imagine the operation would fail but the application might hang for a bit and retry to establish the connection. Much like an http connection, just try a few times before an absolute failure. You'd have to test it out though. Like with NFS or SMB Kodi expects that the connection will normally be open and for use, if the thing reboots during a file operation expect some unexpected behavior.

There isn't anything wrong with just doing a blatant cli command like you have (ie, it would work) but there are a lot of unknowns across Kodi systems that don't really make it an ideal solution. The first is just OS. You might have Linux but Kodi exists across Android, iOS, Windows, etc. Offering SSH as a destination but then it doesn't work on all other platforms kind of defeats the purpose of using python as a cross-platform solution.

I guess overall just executing the backup as though it were a bash script doesn't offer enough benefits across the entire user base. If that is something you still really want to do, instead of using the SFTP source, you can always modify the script to do that. Probably an easier way would be to write the bash script yourself, and then use the Cron addon to schedule it. Basically make it yourself. You could either kick the thing off with a call to a python script or checkout the System commands for Kodi and use that as your cron command

matrix1000 commented 5 years ago

Ok, you are right. I forgot that Kodi is also used on non Linux systems. Thank you very much for your detailed help and your time.