Samba Backup: Create and store backups on a Samba share

David, my config is set up to create a partial snapshot, excluding my databases and other large addons, every morning at 2:16am

host: 10.1.1.10
share: Backup
target_dir: Hassio
username: hassio
password: [redacted]
keep_local: 10
keep_remote: 30
trigger_time: '02:16'
trigger_days:
  - Mon
  - Tue
  - Wed
  - Thu
  - Fri
  - Sat
  - Sun
exclude_addons:
  - 15ef4d2f_esphome
  - 15ef4d2f_esphome-dev
  - a0d7b954_influxdb
  - core_mariadb
  - a0d7b954_vscode
exclude_folders:
  - addons/local
backup_name: '{type} Snapshot (Samba Backup) {date} v{version}'
backup_password: ''

I have an automation that triggers a partial snapshot including my databases weekly at 5:26am on Tuesdays:

- alias: 'Full Samba Backup'
  trigger:
    platform: time
    at: '05:26:00'
  condition:
    condition: time
    weekday:
    - tue
  action:
  - service: hassio.addon_stdin
    data:
      addon: 15d21743_samba_backup
      input:
        command: trigger
        backup_name: 'Database Snapshot (Samba Backup) {date} v{version}'
        exclude_addons: [ 15ef4d2f_esphome, 15ef4d2f_esphome-dev, a0d7b954_vscode ]

This is quite an intensive operation.

I also have another automation that alerts me when Samba backup is running and has succeed or failed:

- alias: Backup Notifications
  trigger:
    platform: state
    entity_id: sensor.samba_backup
  condition:
  - condition: not
    conditions:
    - condition: state
      entity_id: sensor.samba_backup
      state: IDLE
  action:
  - service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "Samba backup {{ states('sensor.samba_backup')|lower }}."
  - service: logbook.log
    data_template:
      name: Samba Backup
      message: "{{ states('sensor.samba_backup')|lower }}"

That works for both the addon and automation triggered snapshots.

Again, thanks a lot Tom! :+1:t2:
The “ Restore Samba Backup sensor on startup“ works perfectly now.

1 Like

Hmmm, very strange. They should be equivalent.

I don’t get it either. Both versions should work.

Sorry if I was not clear enough: You only need to delete/rename a sensor if you manually created one before. If you never added a “Samba Backup” sensor entry in your configuration.yaml, you do not have to do anything.

I never created manually a “Samba Backup” sensor entry.
It was created when I upgraded to version 4.0, but gone after restart(s).
After I added Tom’s code it was OK again.

Delete the mqtt sensor (you must have made) from your config and restart. Then upgrade the addon.

Very nice backup tooling!! Thanks a lot

Backup integration works great. :+1: loving it!

Working nicely in node red! Sends iOS notification if backup failed.

1 Like

Today my system crashed and I need to restore my system to a newly installed rpi4
I have Samba Backup from last night, what’s the right procedure to restore this backup to a new fresh installation?

Thanks,
Rien

  1. Fix your power supply issue that caused the crash.
  2. Flash a fresh copy of home assistant to an SD card.
  3. Boot up home assistant, create an account, and log in.
  4. Enable advanced mode in your profile.
  5. Install the SAMBA addon and configure it.
  6. Upload your last good snapshot to config/backup via the home assistant SAMBA share.
  7. Go to Supervisor / Snapshots in home assistant
  8. Use the refresh icon top right to make the uploaded snapshot visible.
  9. Click on your snapshot, restore from your snapshot.
6 Likes

That’s worthy of its own topic in Community Guides.

1 Like

Good idea. I write one up with screenshots tomorrow.

Hi Tom,

I used another power supply to troubleshoot my issues. The one I normally use in production does not have the power issues.

I did step 1-8. But when I click on restore selected and click on OK if I’m sure, nothing seems to happen.
Even if I create a new snapshot and try to restore that one, same result.

Hi Tom,

I love this idea but it seems I am a tad dim… I managed to get your addon but I am stuck in the config.

My setup:
Network storage :: Synology NAS ( 192.168.1.235 )(with a shared drive /ha_backup which I can access with windows using user and pass)

HA :: Rpi4 with Home Assistant ( 192.168.1.170 ) booting from SSD (Had to use the Beta 5.2 as the vanilla version does not support SSD booting)

Config:

Copy to clipboard

host: 192.168.1.235
share: backup
target_dir: /ha-backup
username: *********
password: *********
keep_local: '5'
keep_remote: '30'
trigger_time: '04:00'
trigger_days:
  - Wed
  - Sun
exclude_addons: []
exclude_folders: []
backup_name: '{type} Snapshot (Samba Backup) {date}'

So in doing this I get the error: ‘Cannot access share. Please check your config.’

Do you mind explaining where I am going wrong??

  • my network drive won’t work as it is not Samba? I have no idea what Synology uses but I would bet it uses Samba…
  • I have to mount it first?
  • I have no idea what to put under your share option, the samba share name? Where do I get this?
  • Did I get it wrong and the host is the local / HA ip and not the samba host?
  • Target directory? I can get to this from windows \192.168.1.235\ha_backup - should I enter the full path?
  • something totally different?

Thank you ever so much!

Frank

This is not my addon. I just use it. Have you tried:

share: ha-backup

Note: no leading /

If you get a “Cannot access share”, the only options that could be wrong are host, share or the credentials, but most likely it’s the share option.

I guess your config should look like this:

host: 192.168.1.235
share: ha_backup
target_dir: ""

It will look like nothing is happening. After a minute or so when you hit F5, the webpage should go unavailable (that’s how you know it’s doing stuff). Depending on the size, it should be back online after 20 minutes or so.

You’re right. I was too impatient or waiting for some sort of confirmation or status update.

Now back on track :slight_smile:

Hello.
I’m trying to configure the add on but i can’t.
I have this setup on the nas:
IP 192.168.1.249
Folder backup: Backup

This is what i see on windows:
image

this is my configuration:

host: 192.168.1.249
share: Backup
target_dir: ''
username: user
password: password
keep_local: all
keep_remote: all
trigger_time: '19:00'
trigger_days:
 - Mon
 - Tue
 - Wed
 - Thu
 - Fri
 - Sat
 - Sun
exclude_addons: []
exclude_folders: []

this is my 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:15:38] INFO: Host: 192.168.1.249
[21:15:38] INFO: Share: Backup
[21:15:38] INFO: Target Dir:
[21:15:38] INFO: Keep local: all
[21:15:38] INFO: Keep remote: all
[21:15:38] INFO: Trigger time: 19:00
[21:15:38] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[21:15:39] INFO: Found local mqtt broker - topic is “samba_backup/#”
[21:15:40] WARNING: protocol negotiation failed: NT_STATUS_CONNECTION_DISCONNECTED
[21:15:40] FATAL: Cannot access share. Please check your config.
/run.sh: line 48: update-status: command not found
[cmd] /run.sh exited 127
[cont-finish.d] executing container finish scripts…
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Thanks