thomasmauerer / hassio-addons

My collection of addons for Home Assistant
MIT License
468 stars 54 forks source link

Failed error after backup, but still seemingly successful #152

Open TB-SE opened 1 year ago

TB-SE commented 1 year ago

After the latest HA update (2023.06.0 and also above) I get this weird failed error, but the backup is visible both in HA and my NAS. Any input on what is suddenly not working? I'm using the samba backup sensor for some other automations which now unfortunately no longer work. 😔

Add-on version: 5.2.0 System: Home Assistant OS 10.2 (aarch64 / yellow) Home Assistant Core: 2023.6.1 Home Assistant Supervisor: 2023.06.1

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/00-banner.sh
-----------------------------------------------------------
 Add-on: Samba Backup
 Create backups and store them on a Samba share
-----------------------------------------------------------
 Add-on version: 5.2.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 10.2  (aarch64 / yellow)
 Home Assistant Core: 2023.6.1
 Home Assistant Supervisor: 2023.06.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
cont-init: info: /etc/cont-init.d/00-banner.sh exited 0
cont-init: info: running /etc/cont-init.d/01-log-level.sh
Log level is set to DEBUG
cont-init: info: /etc/cont-init.d/01-log-level.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[23-06-09 11:46:17] INFO: ---------------------------------------------------
[23-06-09 11:46:17] INFO: Host/Share: 192.168.50.200/Tommy
[23-06-09 11:46:17] INFO: Target directory: HA-backup
[23-06-09 11:46:17] INFO: Keep local/remote: 2/14
[23-06-09 11:46:17] INFO: Trigger time: manual
[23-06-09 11:46:17] INFO: ---------------------------------------------------
[23-06-09 11:46:18] DEBUG: Backups local/remote: 19/13
[23-06-09 11:46:18] DEBUG: Total backups succeeded/failed: 79/4
[23-06-09 11:46:18] DEBUG: Last backup: 2023-06-07 04:52
[23-06-09 11:46:19] DEBUG: putting file samba-tmp123 as \HA-backup\samba-tmp123 (0.0 kb/s) (average 0.0 kb/s)
[23-06-09 11:46:19] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-06-09 11:46:19] DEBUG: API Status: 200
[23-06-09 11:46:19] DEBUG: API Response: {"entity_id":"sensor.samba_backup","state":"IDLE","attributes":{"friendly_name":"Samba Backup","backups_local":"19","backups_remote":"13","total_backups_succeeded":"79","total_backups_failed":"4","last_backup":"2023-06-07 04:52"},"last_changed":"2023-06-09T09:09:03.704151+00:00","last_updated":"2023-06-09T09:09:03.704151+00:00","context":{"id":"01H2FPN6JRKMR7S6ED8STC58M1","parent_id":null,"user_id":"ed3260cd47b34d09991435f7d6ef0130"}}
[23-06-09 11:46:19] INFO: Samba Backup started successfully
[23-06-09 11:46:19] DEBUG: Starting stdin listener ...
[23-06-09 11:50:47] DEBUG: Input received: "restore-sensor"
[23-06-09 11:50:48] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-06-09 11:50:50] DEBUG: API Status: 201
[23-06-09 11:50:50] DEBUG: API Response: {"entity_id":"sensor.samba_backup","state":"IDLE","attributes":{"friendly_name":"Samba Backup","backups_local":"19","backups_remote":"13","total_backups_succeeded":"79","total_backups_failed":"4","last_backup":"2023-06-07 04:52"},"last_changed":"2023-06-09T09:50:50.270305+00:00","last_updated":"2023-06-09T09:50:50.270305+00:00","context":{"id":"01H2FS1PCY8V33AVSNC5XHNG0V","parent_id":null,"user_id":"ed3260cd47b34d09991435f7d6ef0130"}}
[23-06-09 11:53:40] DEBUG: Input received: "trigger"
[23-06-09 11:53:40] INFO: Backup running ...
[23-06-09 11:53:41] DEBUG: Backups local/remote: 19/13
[23-06-09 11:53:41] DEBUG: Total backups succeeded/failed: 79/4
[23-06-09 11:53:41] DEBUG: Last backup: 2023-06-07 04:52
[23-06-09 11:53:41] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-06-09 11:53:41] DEBUG: API Status: 200
[23-06-09 11:53:41] DEBUG: API Response: {"entity_id":"sensor.samba_backup","state":"RUNNING","attributes":{"friendly_name":"Samba Backup","backups_local":"19","backups_remote":"13","total_backups_succeeded":"79","total_backups_failed":"4","last_backup":"2023-06-07 04:52"},"last_changed":"2023-06-09T09:53:41.642845+00:00","last_updated":"2023-06-09T09:53:41.642845+00:00","context":{"id":"01H2FS6XRAN5Q571224AV2RW1F","parent_id":null,"user_id":"ed3260cd47b34d09991435f7d6ef0130"}}
[23-06-09 11:53:41] INFO: Creating backup "Full Backup 2023.6.1 2023-06-09 11:53"
[23-06-09 12:46:36] INFO: Copying backup b0a4bc2f (Samba_Backup_Full_Backup_2023_6_1_2023_06_09_11_53.tar) to share
[23-06-09 12:46:36] WARNING: b0a4bc2f.tar does not exist
[23-06-09 12:46:36] WARNING: Could not copy backup b0a4bc2f to share. Trying again ...
[23-06-09 12:46:41] WARNING: b0a4bc2f.tar does not exist
[23-06-09 12:46:43] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-06-09 12:46:43] DEBUG: API Status: 200
[23-06-09 12:46:43] DEBUG: API Response: {"entity_id":"sensor.samba_backup","state":"FAILED","attributes":{"friendly_name":"Samba Backup","backups_local":"15","backups_remote":"11","total_backups_succeeded":"79","total_backups_failed":"5","last_backup":"2023-06-07 04:52"},"last_changed":"2023-06-09T10:46:43.187841+00:00","last_updated":"2023-06-09T10:46:43.187841+00:00","context":{"id":"01H2FW80QKMSMZW09AHT4B01KY","parent_id":null,"user_id":"ed3260cd47b34d09991435f7d6ef0130"}}
[23-06-09 12:46:53] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-06-09 12:46:53] DEBUG: API Status: 200
[23-06-09 12:46:53] DEBUG: API Response: {"entity_id":"sensor.samba_backup","state":"IDLE","attributes":{"friendly_name":"Samba Backup","backups_local":"15","backups_remote":"11","total_backups_succeeded":"79","total_backups_failed":"5","last_backup":"2023-06-07 04:52"},"last_changed":"2023-06-09T10:46:53.455889+00:00","last_updated":"2023-06-09T10:46:53.455889+00:00","context":{"id":"01H2FW8ARFJ7YS95AE5BV4N2R2","parent_id":null,"user_id":"ed3260cd47b34d09991435f7d6ef0130"}}
[23-06-09 12:46:53] INFO: Backup finished
mdisabato commented 1 year ago

I have a similar (the same?) issue:

s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting cont-init: info: running /etc/cont-init.d/00-banner.sh

Add-on: Samba Backup Create backups and store them on a Samba share

Add-on version: 5.2.0 You are running the latest version of this add-on. System: Home Assistant OS 10.2 (aarch64 / raspberrypi4-64) Home Assistant Core: 2023.6.1 Home Assistant Supervisor: 2023.06.1

Please, share the above information when looking for help or support in, e.g., GitHub, forums or the Discord chat.

cont-init: info: /etc/cont-init.d/00-banner.sh exited 0 cont-init: info: running /etc/cont-init.d/01-log-level.sh Log level is set to INFO cont-init: info: /etc/cont-init.d/01-log-level.sh exited 0 s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [23-06-11 05:46:50] INFO: --------------------------------------------------- [23-06-11 05:46:50] INFO: Host/Share: 10.1.10.181/pibackup [23-06-11 05:46:50] INFO: Target directory: /ha-prod [23-06-11 05:46:50] INFO: Keep local/remote: 10/15 [23-06-11 05:46:50] INFO: Trigger time: 03:33 [23-06-11 05:46:50] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun [23-06-11 05:46:50] INFO: --------------------------------------------------- [23-06-11 05:46:58] INFO: Samba Backup started successfully [23-06-11 05:47:08] INFO: Backup running ... [23-06-11 05:47:09] INFO: Creating backup "haprod 2023.6.1 Full 2023-06-11 05:47" [23-06-11 05:49:57] INFO: Copying backup 029e9d9f (Samba_Backup_haprod_2023_6_1_Full_2023_06_11_05_47.tar) to share [23-06-11 05:49:58] WARNING: 029e9d9f.tar does not exist [23-06-11 05:49:58] WARNING: Could not copy backup 029e9d9f to share. Trying again ... [23-06-11 05:50:03] WARNING: 029e9d9f.tar does not exist [23-06-11 05:50:14] INFO: Backup finished

This started after the last HA update. I used the new Storage option to create a NFS share for backuips. This works with the internal backup function, but it may be causing issues with Samba Backup. The add-on creates the .tar file on the NAS. If the add-on is expecting to find the backup file on the SD-RAM and cannot locate it on the NAS, it cannot copy it. Actually, at that point, a rename would be good enough, since I am using the same NAS folder for both.

TB-SE commented 1 year ago

This started after the last HA update. I used the new Storage option to create a NFS share for backuips. This works with the internal backup function, but it may be causing issues with Samba Backup. The add-on creates the .tar file on the NAS. If the add-on is expecting to find the backup file on the SD-RAM and cannot locate it on the NAS, it cannot copy it. Actually, at that point, a rename would be good enough, since I am using the same NAS folder for both.

OMG, I feel so stupid for not realising this sooner. 🤦‍♂️ You are absolutely right @mdisabato. I did the exact same thing and as you mentioned, the issue arrives from the fact that the file is no longer found where the addon expects it to be.

I can attest, setting the default backup location back to the internal storage makes the issue go away completely. I'll keep using the internal drive for manual backups for now.

mdisabato commented 1 year ago

There is a post on the forum (https://community.home-assistant.io/t/samba-backup-create-and-store-backups-on-a-samba-share/199471/577) that mentions creating the backup on the NAS reduces the write-count on the SD-RAM. I would like to see the process amended to be:

The actual backup might take longer because of network loading (definitely a variable), but that will also depend on the SD-RAM access speed.

bcutter commented 1 year ago

I see similar stuff in #146 for a long time, long before the native network storage support of HA. And I even don't use that new feature, only SAMBA backup.

bcutter commented 1 year ago

This addon is unmaintained, isn't it?

GeoffMorg commented 1 year ago

Feels like it. I have just found I have the same issue

walterb65 commented 1 year ago

Since a couple of days after upgrade HA to 2023.10.1 my backup fails. Log shows [23-10-08 00:00:16] INFO: Backup running … [23-10-08 00:00:18] INFO: Creating backup “Samba Backup 2023-10-08 00:00” parse error: Invalid numeric literal at line 1, column 5 [23-10-08 03:00:30] INFO: Backup finished Notification report Backup failed

Loic691 commented 9 months ago

Same for me. I think the addon is unmaintained ? @thomasmauerer ?

The bug is in this main function

function copy-backup {
    local store_name
    local input
    local count

    if [ "$SLUG" = "null" ]; then
        bashio::log.error "Error occurred! Backup could not be created! Please try again"
        return 1
    fi

    store_name=$(generate-filename "$SNAP_NAME")

    # append number to filename if already existing
    input="$(eval "${SMB} -c 'cd \"${TARGET_DIR}\"; ls'")"
    count=$(echo "$input" | grep "\<$store_name.*\.tar\>" | wc -l)
    (( "$count" > 0 )) && store_name="${store_name}${count}.tar" || store_name="${store_name}.tar"

    bashio::log.info "Copying backup ${SLUG} (${store_name}) to share"
    cd /backup || return 1

    if ! run-and-log "${SMB} -c 'cd \"${TARGET_DIR}\"; put ${SLUG}.tar ${store_name}'"; then
        bashio::log.warning "Could not copy backup ${SLUG} to share. Trying again ..."
        sleep 5
        run-and-log "${SMB} -c 'cd \"${TARGET_DIR}\"; put ${SLUG}.tar ${store_name}'"
    fi
}