Samba Backup: Create and store backups on a Samba share

did you try enclosing the password in single-quote?

'3hdgh\"j5'

Would you be open to sharing the code? This seems like an good use case for me to implement while I am still learning Node Red for my own use.

Many thanks.

Are you referring to the post by inkylatte?

It looks pretty straightforward to me. The flow just logs the result of the backup. What do you want to do in Node Red anyway? SambaShare has made daily backups to an NAS super simple. If I want to verify that snapshots are saved, I just look at the destination directory.

I am envisioning an administrative dashboard. At a glance I am looking to monitor the protections and state of affairs. Eventually I would direct outputs to a MYSQL or similar db in the event I want to trend something, HA or things I pull through.

I was envisioining building with NodeRed, bu tI am just learning the paradigm. Examples are helpful, especially practical ones I might implement myself.

Agreed, the samba backup tool to my NAS is a breeze, as is my secondary b/u to Googledrive. (I must sound like i am running on a MicroSD, which I am, for now, but that will change too down the road.)

Samba Backup saved my bacon last week. I had to do a complete machine recovery and it was simple to just recover from the previous night’s backup.
Nice nice addon!

3 Likes

@thomasmauerer
Is possible show the custom date dd-mm-yy ?
Thank’s for your excellent work!

That would be an enhancement, but currently the date format for the sensor and the snapshot name is fixed.

Can someone please tell me what’s wrong here. Here is my Samba Backup config:

host: 192.168.1.54
share: mntD
target_dir: snapshots
username: nuc
password: xxxxxx
keep_local: '5'
keep_remote: '5'
trigger_time: '00:10'
trigger_days:
  - Mon
  - Tue
  - Wed
  - Thu
  - Fri
  - Sat
  - Sun
exclude_addons: []
exclude_folders: []
backup_name: '{type} Snapshot {version} {date}'
workgroup: MSHOME
compatibility_mode: false

When I start the addon, I get this in the 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.
[15:56:13] INFO: Host: 192.168.1.54
[15:56:13] INFO: Share: mntD
[15:56:13] INFO: Target Dir: snapshots
[15:56:13] INFO: Keep local: 5
[15:56:13] INFO: Keep remote: 5
[15:56:13] INFO: Trigger time: 00:10
[15:56:13] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[15:56:13] WARNING: tree connect failed: NT_STATUS_BAD_NETWORK_NAME
[15:56:13] FATAL: Cannot access share. It seems that your configured share does not exist.
[15:56:13] FATAL: I found the following shares on your host. Did you mean one of those?
[15:56:13] FATAL: 
	Sharename       Type      Comment
	---------       ----      -------
	print$          Disk      Printer Drivers
	nuc             Disk      Nuc/ folder
	config          Disk      Home Assistant config folder
	steve           Disk      Shared folder on Steve
	snapshots       Disk      Home Assistant config folder
	mntD            Disk      SATA drive on NUC
	IPC$            IPC       IPC Service (NUC server (Samba, Ubuntu))
	Artisan-1430    Printer   EPSON Artisan 1430
SMB1 disabled -- no workgroup available
[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.

Even the log file shows that share mntD was found. The privileges of mntD and mntD/snapshots are chmod 777.

I solved it by creating a sensor

 - platform: template
    sensors:
      ultimo_backupsamba:
        friendly_name: 'Ultimo Backup Samba'
        unit_of_measurement: ""    
        value_template:  >

          {{ as_timestamp(states.sensor.samba_backup.attributes.last_backup) | timestamp_custom('%d/%m/%Y - %H:%M') }}
1 Like

On startup I always get the message:

[20:28:33] INFO: Host: 192.168.178.1
[20:28:33] INFO: Share: FRITZ.NAS
[20:28:33] INFO: Target Dir:
[20:28:33] INFO: Keep local: all
[20:28:33] INFO: Keep remote: all
[20:28:33] INFO: Trigger time: 20:10
[20:28:33] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[20:28:34] WARNING: NT_STATUS_ACCESS_DENIED opening remote file \samba-tmp123
NT_STATUS_NO_SUCH_FILE listing \samba-tmp123
[20:28:34] FATAL: Missing write permissions on target folder. Please check your share settings.
[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.

Does someone know why??

I found my mistake!! I didn´t set a target directory!!

I have exactly the same issue.

And on top, home assistant UI does not allow me to enter or change an IP address as host in the configuration area. Only IP address with an additional / works.

My SMB share is running on Synology NAS.

[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.
[19:54:49] INFO: Host: 192.168.XX.XX/
[19:54:49] INFO: Share: backup
[19:54:49] INFO: Target Dir: home-assistant
[19:54:49] INFO: Keep local: all
[19:54:49] INFO: Keep remote: all
[19:54:49] INFO: Trigger time: 00:00
[19:54:49] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[19:54:50] WARNING: tree connect failed: NT_STATUS_BAD_NETWORK_NAME
[19:54:50] FATAL: Cannot access share. It seems that your configured share does not exist.
[19:54:50] FATAL: I found the following shares on your host. Did you mean one of those?
[19:54:50] FATAL: 
	Sharename       Type      Comment
	---------       ----      -------
	backup          Disk      
	XXXX            Disk      
	XXXXX           Disk      
	XXXXXXXXX       Disk      
	XXXXX           Disk      
	XXXXX           Disk      
	XXXXXXXXXXXX    Disk      System default shared folder
	XXXXX           Disk      
	XXX             Disk      System default shared folder
	XXXX            IPC       IPC Service ()
SMB1 disabled -- no workgroup available
[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.

MyConfiguration:

host: 192.168.XX.XX/
share: backup
target_dir: home-assistant
username: XXXXXXXXXX
password: XXXXXXXXXX
keep_local: all
keep_remote: all
trigger_time: '00:00'
trigger_days:
  - Mon
  - Tue
  - Wed
  - Thu
  - Fri
  - Sat
  - Sun
exclude_addons: []
exclude_folders: []
compatibility_mode: false
log_level: info

Any ideas what the problem could be? Running HA with 2021.4.6.

With a little trial & error I could finally outsmart the UI and enter an IP address.
I just got it to enter the IP address and the UI asked me for restarting the add-on. After that the change was taken. But still looks like this …

Finally I have to wait and see tonight if the backup is working. Up to now I am getting this in the logs, which looks good from my point of view:

[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.
[20:08:25] INFO: Host: 192.168.XX.XX
[20:08:25] INFO: Share: backup
[20:08:25] INFO: Target Dir: home-assistant
[20:08:25] INFO: Keep local: all
[20:08:25] INFO: Keep remote: all
[20:08:25] INFO: Trigger time: 00:00
[20:08:25] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[20:08:26] DEBUG: Backups local: 0
[20:08:26] DEBUG: Backups remote: 0
[20:08:26] DEBUG: Total backups succeeded: 0
[20:08:26] DEBUG: Total backups failed: 0
[20:08:26] DEBUG: Last backup: never
[20:08:26] DEBUG: API Status: 200
[20:08:26] DEBUG: API Response: {"entity_id": "sensor.samba_backup", "state": "IDLE", "attributes": {"friendly_name": "Samba Backup", "backups_local": "0", "backups_remote": "0", "total_backups_succeeded": "0", "total_backups_failed": "0", "last_backup": "never"}, "last_changed": "2021-05-04T18:05:26.278560+00:00", "last_updated": "2021-05-04T18:05:26.278560+00:00", "context": {"id": "**************************************", "parent_id": null, "user_id": "**********************************"}}
[20:08:27] DEBUG: 
[20:08:27] DEBUG: putting file samba-tmp123 as \home-assistant\samba-tmp123 (0.0 kb/s) (average 0.0 kb/s)
[20:08:27] DEBUG: Starting main loop ...
[20:08:27] DEBUG: Starting stdin listener ...

Hi everybody, new at HA and this my first comment :wave:@thomasmauerer great job !!! my setting working like a charm !!
2 questions:

:yellow_circle: A better way to save file format name;

backup_name: '{type} Snapshot (Samba_Backup) {date} v{version}'

igual to Samba_Backup_Full_Snapshot_(Samba_Backup)_2021_05_18_00_00_v2021_5_4.tar

(too many Samba_Backup names (I ask because I read in a previous post of yours that it was necessary to be able to erase the old ones or something like that)

:yellow_circle: Do how to save in another location (drive) intead of samba share folder (HA drive)? to be a real backup (another location),automatically course; if it is not possible then I was thinking in a task schedule using xcopy of the folder every day (bat file)
Do any other better idea?

Thank you. :white_check_mark:

Is there a way to clear the failed backup counter? I ran mine up during initial testing and have not had a failure since.

The prefix is necessary and will be automatically added. But you could for example omit the “(Samba_Backup)” in the middle of the name.

I don’t exactly understand the question. You can backup to everywhere you want. It just needs to be a shared folder. This could be a NAS or simply a folder on a Windows or Linux machine.

There is a hidden file inside the backup folder on your HA device called “.samba_backup.sensor”. If you delete it, everything will be reset.

Thanks, adjusted file and “problem” resolved.

The prefix is necessary and will be automatically added. But you could for example omit the “(Samba_Backup)” in the middle of the name.

Exactly what I was looking for !

I don’t exactly understand the question. You can backup to everywhere you want. It just needs to be a shared folder. This could be a NAS or simply a folder on a Windows or Linux machine.

Perfect !!, I will work in your way … just in case you are looking for some alternative I find FreeFileSyncs it look like amazing tool !!

Thank you @thomasmauerer , great work again !! … :100: