robweber / xbmcbackup

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

Zipped Backup to nextcloud webdav not possible (write error, 0B files) #148

Closed chris42 closed 4 years ago

chris42 commented 5 years ago

When trying to get a zipped backup running, I get the error Copy - Failed write to file davs... However when deactivating archive compression it writes on the same dav share in a folder. I am on

It seems to be something wrong with the zip handling, hence I tried to install the archive addon for virtual filesystems, however that did not help.

robweber commented 5 years ago

When doing a zip archive the entire archive is created locally and then the result zip file is pushed over to your destination. The Kodi VFS system doesn't allow writing directly to a zip archive so it's done with python directly.

Not sure what options you have turned on, but have you tried doing a small subset of the backup options to see if that makes a difference? I'm thinking something like config files only, with compression turned on, to see if that works. I'm not super familiar with WebDav, but I do recall it is an extension of the http protocol. It's possible that your destination server has a limit for single POST (or PUT) type requests that is rejecting the upload a single, large, zip file.

chris42 commented 5 years ago

So I found two things:

  1. For some reason backup add-on started to do backups again and writing zips to the webdav. However the zip is 0KB and can't be opened?
  2. I tried to change the files included, but always with the same result of - now - the 0KB zip file.

I did not change anything over the last days, other than reinstalling the backup add-on over and over and cleaning up the kodi database. Is there any debug log for the add-on I can turn on?

robweber commented 5 years ago

A 0KB zip file might be a permissions error. Can you load a log file to pastbin or something like that from one of your recent attempts. Another thing to try is just delete the temp zip files created in the Kodi tmp directory (system dependent location). If it's a permissions thing an old file in that directory could be the problem in creating a new one.

chris42 commented 5 years ago

I created a new log with debug logging activated: https://pastebin.com/EXzDTRFZ In /tmp and/storage/.kodi/temp I could not find any zip files.

For the backup I had config files and databases activated. Can't see any error...

robweber commented 5 years ago

At this point I think it's either making the zip file correctly and then there is an error in transfer, or the zip file really is 0KB and it's messed up the write action.

In the code can you comment out this line? It will prevent the addon from deleting the zip file after the transfer. You should be able to find it in the temp folder and see if it is the same one as what is being copied or not.

Alternatively here is a branch of the addon with the remove already commented out. If you want you can download the zip and load into Kodi directly (uninstall current version).

chris42 commented 5 years ago

The zip gets created and seems to be ok (it opens and content looks like backup). Hence it has to be something with the transfer to the webdav server.

robweber commented 5 years ago

What is the size of the file on your system? I might have to pitch this back to the Kodi forum if it's within the transfer. The addon hands the file back off to the Kodi VFS system to do the actual transferring. Might need clarification at that level.

chris42 commented 5 years ago

It is ~19MB with database and config files marked for backup. Seems that there is a problem with the webdav copy in kodi. I can see the webdav target in the file manager and access it to see the files contained. I can copy from webdav to kodi, but as soon as kodi tries to copy to the webdav the file size gets 0KB. I tried that also with the file manager. Same result

I found this in the forum from 2015, with apparently someone with similar problems. Apparently it worked for me till September 2018...

chris42 commented 4 years ago

So I searched a bit more and it seems to be a nextcloud issue. I can find an error in the nextcloud log file with File with name LibreElec-Backup\/test.zip could not be located","Code":0 However that came up in multiple issues within nextcloud, but could not see a definite solution.

I changed the title of the issue, if someone has a similar experience. Will close for now. If I find a solution, I will report back.

chris42 commented 4 years ago

Ok, after checking 20+ issues, I found the (for me) relevant one. It is a problem with chunked transfers and an open issue with nextcloud. #7995 The solution is to set fastcgi_request_buffering on in your nginx configuration.

@robweber Sorry for bothering you and thanks for your help!

robweber commented 4 years ago

Interesting, thanks for the follow-up. When doing some Google searches earlier I did see some issues related to webdav on owncloud. I know Nextcloud is a fork of that, although not sure how closely related they are anymore.