Samba Backup: Create and store backups on a Samba share

The share name is ha-backups :heavy_check_mark:
But you didn’t define the target directory: target_dir: '' :interrobang:

The “ha-backups” is the root. Just in case I put a couple of folders in there, one with the same name and one with a new name. Restarted and reran. No backup. The trace shows it start then finish in 10 seconds. Normal log:

[s6-init] making user provided files available at /var/run/s6/etc…exited 0.
[s6-init] ensuring user provided files have correct perms…exited 0.
[fix-attrs.d] applying ownership & permissions fixes…
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts…
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[21:24:51] INFO: Host: 192.168.3.33
[21:24:51] INFO: Share: ha-backups
[21:24:51] INFO: Target Dir: ha-backups
[21:24:51] INFO: Keep local: all
[21:24:51] INFO: Keep remote: all
[21:24:51] INFO: Trigger time: manual

Just not enough details for problem determination for a quasi-newbie.
It worked the first time when I installed in a couple of weeks ago then nothing sense.

Did you restart the Add-on “Samba Backup” after you defined target_dir: ha-backups within the configuration file?

Yes. I think the issue is on the windows machine where the share exists. There is an entry in the error log and unfortunately, Microsoft may have locked some service down as the instructions to fix no longer work (as noted by many people). Still looking.

Error Log Text:

The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID 
{C2F03A33-21F5-47FA-B4BB-156362A2F239}
 and APPID 
{316CDED5-E4AE-4B15-9113-7055D84DCC97}
 to the user NIKITA\Administrator SID (S-1-5-21-2644161797-1841032800-167038231-500) from address LocalHost (Using LRPC) running in the application container Microsoft.Windows.ShellExperienceHost_10.0.19041.1023_neutral_neutral_cw5n1h2txyewy SID (S-1-15-2-155514346-2573954481-755741238-1654018636-1233331829-3075935687-2861478708). This security permission can be modified using the Component Services administrative tool.

I never did get this to work on Windows [again]. I have a Linux server and moved the automation to backup there. Works like a champ but I wish the backup would display error messages when it fails.

I saw that the card formatting issue was already closed, but I did run into errors as well. Just commenting with a simple fix that worked for me that allowed me to kept the icons:

Fix: After pasting in the card yaml, move these 3 lines from the bottom of the card to the top. Then you can save it.

show_header_toggle: false
title: Samba Backup
type: entities

I’m honestly not sure why that fixed it. If I paste a brand new card with the 3 lines at the top - I receive the same errors and moving them back to the bottom allowed me to save it without errors.

To trigger manual backups from a Lovelace button, you can paste this into a Manual card:
image

name: Manual Samba Backup
icon: mdi:database
type: button
tap_action:
  action: call-service
  service: hassio.addon_stdin
  service_data:
    addon: 15d21743_samba_backup
    input: trigger
show_state: true

Since this thread is getting kinda long, I created a guide that includes installation, creating a Samba share, status card, notification automation, and manual trigger button here.

4 Likes

I noticed that with 2021.9 they are changing over the name of snapshot to backup (with snapshot removed by 2012.11). Assume you’re planning a change in line with this?

Thank you for this addon. Seems to work great!

I only have one problem, related with my Synology NAS (still on version 6.x, cause I have way too many stuff that will break when I update to 7.x now :slight_smile: ), hopefully someone knows how to fix this…

I only can get this to work with the ‘main-account’ of my synology. But, for security-reasons, that’s the login wich I don’t want to use for things like this…

Give all R/W permissions isn’t enough to get this to work over SMB with my synology with another account as my main.

Samba Backup 5.0.0 is released which includes some improvements and uses the updated supervisor API. The term “snapshot” is now replaced with “backup” also in this addon.

Important: Make sure that you are running supervisor 2021.08.0 or a newer version before updating, since there were some API changes which affect this add-on.

Happy updating :grinning:

8 Likes

Do I stille need the automation to reset samba backup sensor ?

Yes, the automation to restore the sensor when HA restarts is still necessary. This cannot be handled in an addon.

I have a request, is it possible to add support for using !secret for username and password?
I’m saving the backups to my Windows machine but I really don’t like the credentials to be seen when you open the configuration tab.

That is supported out of the box. You can use it if you want.

username: '!secret your_user'
password: '!secret your_pass'

After update from version 4.5 to 5, i got a problem with my Samba Backup.

  1. Snapshot not rename as i set on configuration
  2. Snapshot not uploaded to my NAS
  3. Full snapshot that created not fully backup my supervisor addon (missing)
  4. Backup keep local and remote not counted as i set on configuration. Still keep more then i set

Is any configuration settings need to change for this version 5?

Edit: Solved this by changing host: homeassistant to the actual IP of the Samba share.

I’ve been recently having ‘connection refused’ errors. Anyone have any ideas what that would mean? I can access the share through Windows without issues.

[21-09-19 20:10:35] WARNING: do_connect: Connection to homeassistant failed (Error NT_STATUS_CONNECTION_REFUSED)
[21-09-19 20:10:35] FATAL: Cannot access share. Unknown reason.

I haven’t changed my configuration recently and it used to work… maybe some unrelated app could be interfering? I also updated the Terminal & SSH app, and HA itself.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[21-09-19 20:10:34] INFO: ---------------------------------------------------
[21-09-19 20:10:34] INFO: Host/Share: homeassistant/wdgreenhdd
[21-09-19 20:10:34] INFO: Target directory: HA Snapshots
[21-09-19 20:10:34] INFO: Keep local/remote: 10/100
[21-09-19 20:10:34] INFO: Trigger time: 04:00
[21-09-19 20:10:34] INFO: Trigger days: Mon Wed Fri
[21-09-19 20:10:34] INFO: ---------------------------------------------------
[21-09-19 20:10:34] DEBUG: Backups local: 10
[21-09-19 20:10:34] DEBUG: Backups remote: 45
[21-09-19 20:10:34] DEBUG: Total backups succeeded: 45
[21-09-19 20:10:34] DEBUG: Total backups failed: 0
[21-09-19 20:10:34] DEBUG: Last backup: 2021-08-27 04:00
[21-09-19 20:10:35] DEBUG: API Status: 200
[21-09-19 20:10:35] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "IDLE", "attributes": {"friendly_name": "Samba Backup", "backups_local": "10", "backups_remote": "45", "total_backups_succeeded": "45", "total_backups_failed": "0", "last_backup": "2021-08-27 04:00"}, "last_changed": "2021-09-19T19:10:35.136159+00:00", "last_updated": "2021-09-19T19:10:35.136159+00:00", "context": {"id": "f5dba03b76c603c1f842256e6104f4dc", "parent_id": null, "user_id": "497af19d59534462a34ccc4ca9b08cfc"}}
[21-09-19 20:10:35] WARNING: do_connect: Connection to homeassistant failed (Error NT_STATUS_CONNECTION_REFUSED)
[21-09-19 20:10:35] FATAL: Cannot access share. Unknown reason.
[21-09-19 20:10:35] DEBUG: API Status: 200
[21-09-19 20:10:35] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "FAILED", "attributes": {"friendly_name": "Samba Backup", "backups_local": "10", "backups_remote": "45", "total_backups_succeeded": "45", "total_backups_failed": "0", "last_backup": "2021-08-27 04:00"}, "last_changed": "2021-09-19T19:10:35.455807+00:00", "last_updated": "2021-09-19T19:10:35.455807+00:00", "context": {"id": "13dcdaee74357961fdbb23e4a813aeef", "parent_id": null, "user_id": "497af19d59534462a34ccc4ca9b08cfc"}}
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Samba-backup 5.0.0, hassOS 2021.9.7

First time setup (configs and logs below). Triggered a manual run and I see this:

Error occurred! Backup could not be created! Please try again

Which I have, several times. Same message. How do I determine what the error is?

I’m able to use smbclient from a different host to connect to the share with the credentials in the config and create new files/folders, and the log below appears to show show that a samba-tmp123 file was successfully created, so I think I’ve ruled out share permission issues.

host: 192.168.x.y
share: hass-snapshots
target_dir: /
username: ********
password: ********
keep_local: 5
keep_remote: all
trigger_time: '04:00'
trigger_days:
  - Mon
  - Tue
  - Wed
  - Thu
  - Fri
  - Sat
  - Sun
exclude_addons: []
exclude_folders: []
backup_name: '{type} Backup {version} {date}'
log_level: debug
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[21-09-23 00:39:49] INFO: ---------------------------------------------------
[21-09-23 00:39:49] INFO: Host/Share: 192.168.x.y/hass-snapshots
[21-09-23 00:39:49] INFO: Target directory: /
[21-09-23 00:39:49] INFO: Keep local/remote: 5/all
[21-09-23 00:39:49] INFO: Trigger time: 04:00
[21-09-23 00:39:49] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[21-09-23 00:39:49] INFO: ---------------------------------------------------
[21-09-23 00:39:49] DEBUG: Backups local: 11
[21-09-23 00:39:49] DEBUG: Backups remote: 38
[21-09-23 00:39:49] DEBUG: Total backups succeeded: 0
[21-09-23 00:39:49] DEBUG: Total backups failed: 1
[21-09-23 00:39:49] DEBUG: Last backup: never
[21-09-23 00:39:49] DEBUG: API Status: 200
[21-09-23 00:39:49] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "IDLE", "attributes": {"friendly_name": "Samba Backup", "backups_local": "11", "backups_remote": "38", "total_backups_succeeded": "0", "total_backups_failed": "1", "last_backup": "never"}, "last_changed": "2021-09-23T05:39:49.938142+00:00", "last_updated": "2021-09-23T05:39:49.938142+00:00", "context": {"id": "dd3259b90ea139d8b8e4c1f473fdcf3a", "parent_id": null, "user_id": "0f0ce351f9944ff2b00a80031876139b"}}
[21-09-23 00:39:50] DEBUG: 
[21-09-23 00:39:50] DEBUG: putting file samba-tmp123 as \samba-tmp123 (0.0 kb/s) (average 0.0 kb/s)
[21-09-23 00:39:50] INFO: Samba Backup started successfully
[21-09-23 00:39:50] DEBUG: Starting stdin listener ...
[21-09-23 00:39:50] DEBUG: Starting main loop ...
[21-09-23 00:40:18] DEBUG: Input received: "trigger"
[21-09-23 00:40:18] INFO: Backup running ...
[21-09-23 00:40:18] DEBUG: Backups local: 11
[21-09-23 00:40:18] DEBUG: Backups remote: 38
[21-09-23 00:40:18] DEBUG: Total backups succeeded: 0
[21-09-23 00:40:18] DEBUG: Total backups failed: 1
[21-09-23 00:40:18] DEBUG: Last backup: never
[21-09-23 00:40:18] DEBUG: API Status: 200
[21-09-23 00:40:18] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "RUNNING", "attributes": {"friendly_name": "Samba Backup", "backups_local": "11", "backups_remote": "38", "total_backups_succeeded": "0", "total_backups_failed": "1", "last_backup": "never"}, "last_changed": "2021-09-23T05:40:18.888817+00:00", "last_updated": "2021-09-23T05:40:18.888817+00:00", "context": {"id": "494704c6b2dc6ec26b3e53a11532faab", "parent_id": null, "user_id": "0f0ce351f9944ff2b00a80031876139b"}}
[21-09-23 00:40:18] INFO: Creating backup "Full Backup 2021.9.7 2021-09-23 00:40"
[21-09-23 00:40:19] ERROR: Error occurred! Backup could not be created! Please try again
[21-09-23 00:40:19] DEBUG: API Status: 200
[21-09-23 00:40:19] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "FAILED", "attributes": {"friendly_name": "Samba Backup", "backups_local": "12", "backups_remote": "38", "total_backups_succeeded": "0", "total_backups_failed": "2", "last_backup": "never"}, "last_changed": "2021-09-23T05:40:19.441193+00:00", "last_updated": "2021-09-23T05:40:19.441193+00:00", "context": {"id": "c95cd724c520a2c4b6e0528335e2dd79", "parent_id": null, "user_id": "0f0ce351f9944ff2b00a80031876139b"}}

Thanks,
-Jason

I don’t think that this message has something to do with copying the Backup to the share. I think it appears because the backup of Home Assistant could not be created. Do you have enough space on your Home Assistant boot device?
Maybe you try to create a backup directly in supervisor/backups to test if backups can be created.

Space is plentiful and I’d been successfully creating backup files daily with an automation until I switched to Samba_backup. I also looking in home_assistant.log for any backup related error messages and found none.

Having said that my automated backup did run at 4:00am this morning and successfully created a full backup, copied it to the SMB share, and deleted local backups as configured. Appears to run fine automated, just not when triggered manually. I’m fine with this arrangement.

That has nothing to do with whether the backup was triggered manually or time-based. The creation of snapshots itself is delegated to the supervisor - it is exactly the same when you trigger a backup via the supervisor UI without this add-on.
And sometimes the creation fails. I don’t know the exact reason. There are already community posts about failed backups, e.g. Creating a snapshot is not possible right now because the system is in freeze state