Sebclem / hassio-nextcloud-backup

Hass.io Add-on: Backup your snapshots to Nextcloud
GNU General Public License v3.0
118 stars 15 forks source link

3rd Party platform compatibility #202

Closed jerkelens closed 1 year ago

jerkelens commented 1 year ago

Describe the bug I am currently using a service that's built on Nextcloud technology. I am even using the nextcloud mobile app to use the service. However, your addon throws an uncaught exception:

[2023-03-13 09:11:36] [info]: Log level: info [2023-03-13 09:11:36] [info]: Backup timeout: 5400000 [2023-03-13 09:11:36] [info]: Satus : Go ! [2023-03-13 09:11:36] [info]: Initializing and checking webdav client... [2023-03-13 09:11:36] [info]: Starting auto clean cron... [2023-03-13 09:11:37] [info]: Starting Cron... [2023-03-13 09:11:37] [info]: Hassio API : Go ! [2023-03-13 09:11:38] [info]: Nextcloud connection : Go ! [2023-03-13 09:36:08] [info]: Local clean done. [2023-03-13 09:36:34] [info]: Stopping addons... [2023-03-13 09:36:34] [info]: ... Ok [2023-03-13 09:36:34] [info]: Creating new snapshot... [2023-03-13 09:38:16] [error]: uncaughtException: Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property '_httpMessage' -> object with constructor 'ClientRequest' --- property 'socket' closes the circle TypeError: Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property '_httpMessage' -> object with constructor 'ClientRequest' --- property 'socket' closes the circle at JSON.stringify () at stringify (/opt/nextcloud_backup/node_modules/express/lib/response.js:1150:12) at ServerResponse.json (/opt/nextcloud_backup/node_modules/express/lib/response.js:271:14) at ServerResponse.send (/opt/nextcloud_backup/node_modules/express/lib/response.js:162:21) at file:///opt/nextcloud_backup/routes/api.js:56:17 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) [09:38:24] INFO: Starting Node... [2023-03-13 09:39:00] [info]: Log level: info [2023-03-13 09:39:00] [info]: Backup timeout: 5400000 [2023-03-13 09:39:00] [info]: Satus : Go ! [2023-03-13 09:39:00] [info]: Initializing and checking webdav client... [2023-03-13 09:39:00] [info]: Starting auto clean cron... [2023-03-13 09:39:01] [info]: Starting Cron... [2023-03-13 09:39:01] [info]: Hassio API : Go ! [2023-03-13 09:39:03] [info]: Nextcloud connection : Go !

To Reproduce Steps to reproduce the behavior: Try to create a backup using the addon.

Expected behavior The backup is generated locally, but never uploaded.

System information

Additional context I'm sorry if this isn't a supported scenario, but I thought: if the app works, why wouldn't this addon?

Sebclem commented 1 year ago

Can you change the log level to debug, retry and add the more detailed logs here please ?

jerkelens commented 1 year ago

[10:20:31] INFO: Starting Node... [2023-03-13 10:20:44] [info]: Log level: debug [2023-03-13 10:20:44] [info]: Backup timeout: 5400000 [2023-03-13 10:20:44] [info]: Satus : Go ! [2023-03-13 10:20:44] [info]: Initializing and checking webdav client... [2023-03-13 10:20:44] [info]: Starting auto clean cron... [2023-03-13 10:20:45] [info]: Starting Cron... [2023-03-13 10:20:45] [info]: Hassio API : Go ! [2023-03-13 10:20:45] [debug]: Nextcloud connection: Success ! [2023-03-13 10:20:45] [debug]: Path /Jeroen/ already exist. [2023-03-13 10:20:45] [debug]: Path /Jeroen/rpi/ already exist. [2023-03-13 10:20:45] [debug]: Path /Jeroen/rpi/22/ already exist. [2023-03-13 10:20:45] [debug]: Path /Jeroen/rpi/22/backups/ already exist. [2023-03-13 10:20:46] [info]: Nextcloud connection : Go ! [2023-03-13 10:22:03] [info]: Stopping addons... [2023-03-13 10:22:03] [info]: ... Ok [2023-03-13 10:22:03] [info]: Creating new snapshot... [2023-03-13 10:22:03] [debug]: Addon to backup:

[2023-03-13 10:22:03] [debug]: Folders to backup:

[2023-03-13 10:22:03] [debug]: Is password protected ? true [2023-03-13 10:34:55] [info]: Snapshot created with id 6c814bfd [2023-03-13 10:34:55] [info]: Downloading snapshot 6c814bfd... [2023-03-13 10:34:56] [debug]: Snapshot size: 213.51 [2023-03-13 10:35:26] [info]: Download success ! [2023-03-13 10:35:26] [debug]: Snapshot dl size : 213.505859375 [2023-03-13 10:35:26] [info]: Uploading snap... [2023-03-13 10:35:27] [debug]: ...URI: https://host.hiden/remote.php/webdav/Jeroen/rpi/22/backups/Manual/Manual-2023.3.3-2023-03-13_1022.tar [2023-03-13 10:35:27] [debug]: ...rejectUnauthorized: true [2023-03-13 10:35:32] [error]: Fail to upload snapshot to nextcloud (RequestError: getaddrinfo EAI_AGAIN < MYHOSTHERE >) ! [2023-03-13 10:35:32] [error]: RequestError: getaddrinfo EAI_AGAIN < MYHOSTHERE > at ClientRequest. (file:///opt/nextcloud_backup/node_modules/got/dist/source/core/index.js:767:107) at Object.onceWrapper (node:events:628:26) at ClientRequest.emit (node:events:525:35) at TLSSocket.socketErrorListener (node:_http_client:494:9) at TLSSocket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26) [2023-03-13 10:35:32] [error]: uncaughtException: Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property '_httpMessage' -> object with constructor 'ClientRequest' --- property 'socket' closes the circle TypeError: Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property '_httpMessage' -> object with constructor 'ClientRequest' --- property 'socket' closes the circle at JSON.stringify () at stringify (/opt/nextcloud_backup/node_modules/express/lib/response.js:1150:12) at ServerResponse.json (/opt/nextcloud_backup/node_modules/express/lib/response.js:271:14) at ServerResponse.send (/opt/nextcloud_backup/node_modules/express/lib/response.js:162:21) at file:///opt/nextcloud_backup/routes/api.js:56:17 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) [10:35:37] INFO: Starting Node...

Sebclem commented 1 year ago

Just to be sure, can you check that it's not the same issue as #201

jerkelens commented 1 year ago

I did check it before posting. I also used an app password that isn't too complex, given older issues. The problem still remains though.

Sebclem commented 1 year ago

Ok, getaddrinfo EAI_AGAIN seams to be related to a DNS lookup time out, can you check that you home assistant host machine can resolve your hostname

jerkelens commented 1 year ago

From the HA box, I can ssh into the cloud storage service. Nothing seems out of the ordinary?

jerkelens commented 1 year ago

Also:

[2023-03-13 12:47:31] [info]: Download success ! [2023-03-13 12:47:31] [debug]: Snapshot dl size : 213.76953125 [2023-03-13 12:47:31] [info]: Uploading snap... [2023-03-13 12:47:31] [debug]: ...URI: https://host.hiden/remote.php/webdav/Jeroen/rpi/22/backups/Manual/Manual-2023.3.3-2023-03-13_1149.tar [2023-03-13 12:47:31] [debug]: ...rejectUnauthorized: true [2023-03-13 12:48:24] [info]: Upload done... [2023-03-13 12:48:24] [info]: ...Upload finish ! (status: 201) [2023-03-13 12:48:24] [debug]: Snapshot size: 213.3 [2023-03-13 12:48:24] [info]: Local clean done.

Afterwards, the file isn't on the cloud storage. Time is plausible given my internet connection, but the file is nowhere to be found. The addon shows the tar under 'snapshots in nextcloud' though.

In addition, I changed the target folder to just '/hassio/' (no quotes). In the log, it says the folder doensn't exist, but it successfully created it. However, that folder is nowhere to be found either. Upon retrying the backup once again, it says the folder does exist. But I can't find it. I will do some digging.

Last but not least: if i disable the SSL slider, I get a slightly different error: [2023-03-13 14:04:49] [debug]: ...URI: http://host.hiden/remote.php/webdav/Hassio/Manual/Manual-2023.3.3-2023-03-13_1022.tar [2023-03-13 14:04:52] [error]: Fail to upload snapshot to nextcloud (Error: write EPIPE) ! [2023-03-13 14:04:52] [error]: Error: write EPIPE at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) < log ends here >

jerkelens commented 1 year ago

It gets weirder, if i do a manual SCP file copy from within the HA terminal, it works and the file appears. I'm guessing a 'platform not supported' might be plausible? :)

Sebclem commented 1 year ago

I can only test on stock Nextcloud, they maybe change the Nextcloud webdav api

jerkelens commented 1 year ago

Possibly. I asked the platform owners to look into it, figure out where the uploads go. They're working on it and will probably get back to me tomorrow. Thanks for your help so far Sebclem!

jerkelens commented 1 year ago

Hi - so the hosting party figured out where my files went, apparently having a different account there, generates a separate file environment, so currently the export is working.

However, this wasn't always the case, in my troubleshooting I changed to different credentials to validate if my current credentials were causing the issue. Upon this change, it wasn't working, that's when I opened this bug report and the first errors were apparent DNS issues.

At this moment is appears to be working. I have scheduled a daily backup, which is created, should this be uploaded automatically? That for some reason requires my manual intervention, after which is works. Could this be related to this issue?

Sebclem commented 1 year ago

Hi, The auto backups should create a new backup, and if there is no error, the created backup should be uploaded to nextcloud.

The created backup is no uploaded automatically? Do you have any errors in logs ?

jerkelens commented 1 year ago

Hi Sebclem,

Backups aren't automatically uploaded for me. If I look into the logs, I still see this recurring error:

[error]: Fail to upload snapshot to nextcloud (RequestError: getaddrinfo EAI_AGAIN < MYHOSTHERE >) !

However, I've been looking into the EAI_AGAIN error, I see errors regarding multi-dotted domain names. My host is stackstorage.com and the domain is < account >.stackstorage.com. Does that differ from nextcloud native by any chance and could it somehow be triggering these issues? I am using local DNS logging, tracing the log shows the connection fails most of the time (EAI_AGAIN) and sometimes succeeds. However, if the connection by the addon fails, I am able to execute an SCP to the host at the near same time. I am lost :(

Sebclem commented 1 year ago

You mean your domain is xxxx.stackstorage.com ? If yes you should not have any issue, just check if in config you don't have a dot on front or at the end

jerkelens commented 1 year ago

Sorry, the parsing of < account > wasn't done right because I didn't use spaces. I indeed have xxxx.stackstorage.com.

jerkelens commented 1 year ago

I did another test: scheduled a backup, it ran but didn't upload. Right afterwards I tried to upload the same file, it worked like a charm. Which I like, but I don't understand why the automated backup generates an EAI_AGAIN, while the manual backup works.

[2023-03-15 15:30:00] [debug]: Cron triggered ! [2023-03-15 15:30:00] [info]: Stopping addons... [2023-03-15 15:30:00] [info]: ... Ok [2023-03-15 15:30:00] [info]: Creating new snapshot... [2023-03-15 15:30:00] [debug]: Addon to backup:

[2023-03-15 15:30:00] [debug]: Folders to backup:

[2023-03-15 15:30:00] [debug]: Is password protected ? false [2023-03-15 15:42:40] [info]: Snapshot created with id 1bf2991d [2023-03-15 15:42:40] [info]: Downloading snapshot 1bf2991d... [2023-03-15 15:42:41] [debug]: Snapshot size: 217.56 [2023-03-15 15:43:10] [info]: Download success ! [2023-03-15 15:43:10] [debug]: Snapshot dl size : 217.55859375 [2023-03-15 15:43:10] [info]: Uploading snap... [2023-03-15 15:43:10] [debug]: ...URI: https://host.hiden/remote.php/webdav/Hassio/Auto/Auto-2023.3.4-2023-03-15_1530.tar [2023-03-15 15:43:10] [debug]: ...rejectUnauthorized: true [2023-03-15 15:43:16] [error]: Fail to upload snapshot to nextcloud (RequestError: getaddrinfo EAI_AGAIN < account >.stackstorage.com) ! [2023-03-15 15:43:16] [error]: RequestError: getaddrinfo EAI_AGAIN < account >.stackstorage.com at ClientRequest. (file:///opt/nextcloud_backup/node_modules/got/dist/source/core/index.js:767:107) at Object.onceWrapper (node:events:628:26) at ClientRequest.emit (node:events:525:35) at TLSSocket.socketErrorListener (node:_http_client:494:9) at TLSSocket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26) [2023-03-15 15:43:16] [error]: uncaughtException: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Fail to upload snapshot to nextcloud (RequestError: getaddrinfo EAI_AGAIN < account >.stackstorage.com) !". UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Fail to upload snapshot to nextcloud (RequestError: getaddrinfo EAI_AGAIN < account >.stackstorage.com) !". [15:43:21] INFO: Starting Node... [2023-03-15 15:43:35] [info]: Log level: debug [2023-03-15 15:43:35] [info]: Backup timeout: 5400000 [2023-03-15 15:43:35] [info]: Satus : Go ! [2023-03-15 15:43:35] [info]: Initializing and checking webdav client... [2023-03-15 15:43:35] [info]: Starting auto clean cron... [2023-03-15 15:43:35] [info]: Starting Cron... [2023-03-15 15:43:36] [info]: Hassio API : Go ! [2023-03-15 15:43:36] [debug]: Nextcloud connection: Success ! [2023-03-15 15:43:36] [debug]: Path /Hassio/ already exist. [2023-03-15 15:43:37] [info]: Nextcloud connection : Go ! [2023-03-15 15:45:54] [info]: Downloading snapshot 1bf2991d... [2023-03-15 15:45:54] [debug]: Snapshot size: 217.56 [2023-03-15 15:46:26] [info]: Download success ! [2023-03-15 15:46:26] [debug]: Snapshot dl size : 217.55859375 [2023-03-15 15:46:26] [info]: Uploading snap... [2023-03-15 15:46:26] [debug]: ...URI: https://host.hiden/remote.php/webdav/Hassio/Manual/Auto-2023.3.4-2023-03-15_1530.tar [2023-03-15 15:46:26] [debug]: ...rejectUnauthorized: true [2023-03-15 15:48:00] [info]: Upload done... [2023-03-15 15:48:01] [info]: ...Upload finish ! (status: 201) [2023-03-15 15:48:02] [debug]: Snapshot size: 215.97 [2023-03-15 15:48:02] [info]: Local clean done.

jerkelens commented 1 year ago

Hi,

This bug can be closed. I tried another addon, that gave an error: "unsupported API response". This indicates that this very nextcloud instance isn't default and I shouldn't expect 100% functionality from an addon. You might however want to filter on nextcloud URL's, just to be sure. Thanks for your assistance!