Samba Backup: Create and store backups on a Samba share

That would certainly be acceptable, I have an mqtt broker.

Previously all I did was send a message to my system monitor Telegram chat group whenever my snapshot started. Having a success / fail message would be vastly superior.

Mqtt message would be great.

Hi guys,

great plugin. Love it. There seems to be an ā€œissueā€ with the time. Probably the container does not run in the right/local timezone. I configured 12/noon and the backup is made at 2pm.

Not a major issue for me, but took me a while to figue it out. Initially I thought it did not work bc of the lag.

Sincerely.
Ralf

Itā€™s running at the correct time for me.

I assume the timezone comes from the host. Is the timezone in your Home assistant setup configured correctly? Can you ssh into your HA instance (or use the Web Terminal) and check whether the ā€˜dateā€™ command matches with your local time?

Just released version 2.2.

From now on the dedicated log functions are used. The verbosity of log output can be controlled with the optional parameter ā€˜log_levelā€™.

In addition to that the add-on now performs a pre-check whether the Samba share is configured correctly, i.e. it is accessible and write access is granted. This should help when troubleshooting SMB configuration problems.

(Will work on mqtt notifications next) :slight_smile:

2 Likes

Here it is, Samba Backup 2.3 with mqtt support is released.

All infos can again be found in the README. But in a nutshell, Samba Backup now publishes its current status via mqtt on topic samba_backup/status. This works out of the box without any configuration if a mqtt broker is present on the device, e.g. the Mosquitto broker add-on. Note that this does not work with external brokers.

The status will be one of the following: IDLE, RUNNING, SUCCEEDED or FAILED. You can receive this information in Home Assistant with a sensor.

sensor:
- platform: mqtt
  name: "Samba Backup"
  state_topic: "samba_backup/status"
3 Likes

Youā€™re really trying hard to tempt me away from my very-inelegant-but-works-perfectly backup method arenā€™t you!

3 Likes

I do my best :laughing:

By the way hereā€™s a possible solution to ā€œautomateā€ getting to the plain files directly in the (Windows) target directory.

set backup=%1
mkdir config
tar -xvf %backup% -C config
cd config
tar -xvf homeassistant.tar.gz
del *.tar.gz

Just put that in a bat file and run it with the tar file as the first parameter.

Should the mqtt notifications work with the Mosquitto addon broker?

Iā€™m not getting anything published to the specified topic.

Edit: I think I see why:

1592842604: New connection from 172.30.33.4 on port 1883.
[INFO] found addons on local database
1592842604: New client connected from 172.30.33.4 as mosq-5p5vLHxP4oiTEMd4jC (p2, c1, k60, u'addons').
1592842604: Client mosq-5p5vLHxP4oiTEMd4jC disconnected.
1592842623: New connection from 172.30.33.4 on port 1883.
1592842623: New client connected from 172.30.33.4 as mosq-iqgSNBEcPSVaVHHQtD (p2, c1, k60, u'addons').
1592842623: Client mosq-iqgSNBEcPSVaVHHQtD disconnected.
1592842633: New connection from 172.30.33.4 on port 1883.
1592842633: New client connected from 172.30.33.4 as mosq-SZJ3eobiNbRkViOPpl (p2, c1, k60, u'addons').
1592842633: Client mosq-SZJ3eobiNbRkViOPpl disconnected.

I donā€™t have an ā€˜addonsā€™ user or allow anonymous users.

Is there a way to specify a username and password for connection to the broker?

Your logs look fine. The ā€œaddonsā€ user is internally created by Home Assistant.
You can see in the logs that the user is found and that a client connects and disconnects multiple times (one for each status update). If the connection does not work, you would see a socket error or something like that.

Are you sure that you not misspelled something in your sensor configuration? Maybe a typo for the state_topic?

If you have the ssh addon installed, you can also check if itā€™s working in the web terminal:

mosquitto_sub -h core-mosquitto -t "samba_backup/status" --username <your-username> --pw <your-password>

My sensor config:

- platform: mqtt
  name: "Samba Backup"
  state_topic: "samba_backup/status"
  icon: mdi:folder-network-outline

Using MQTT explorer I see no topic:

samba_backup/status

I see no topic starting with sambaā€¦

and the device state has stayed at ā€œunavailableā€ for the last two backups.

I added the user ā€œaddonsā€ to my ACL (access control list) and now it fuctions as expected.

Is that user account displayed in Configuration > Users?

Because I donā€™t see it on my Supervised system. Iā€™m using the Mosquitto Broker Add-on and it automatically allows connection for accounts listed in Users. The only system-generated account listed in Users is hass.io.

No the user is not displayed. But itā€™s mentioned in the mosquitto addon docu:

[ā€¦] For the internal Home Assistant ecosystem, we register homeassistant and addons , so these may not be used as user names.

Iā€™m not using the addons user hardcoded. This comes directly from a bashio service call, so this should be ok. And actually I rule out authentication problems as the logs clearly show that the client connects and disconnects successfully. The problem must be something else, but I donā€™t know it yet.

1 Like

Did you see this addition I made to my post?

1 Like

Oops did not see that.
Ah youā€™re using an ACL. That explains it - then itā€™s a permission issue writing to the topic.

Really great add-on! Thank you @thomasmauerer

1 Like

Hi,

I have 2 issues with the Samba backup. It does create the backup files on my NAS, but

  1. The file names are like ā€˜23cad1b0.tarā€™ and ā€˜589ad231.tarā€™, despite the fact I use a naming convention
  2. The MQTT sensor is not working, I do not receive any topic on ā€œsamba_backup/statusā€ while other topics are received without issues.

Here is my config:

host: n01.local
share: Backup
target_dir: HomeAssistant
username: user
password: password
keep_local: 3
keep_remote: 30
trigger_time: '04:00'
trigger_days:
  - Mon
  - Tue
  - Wed
  - Thu
  - Fri
  - Sat
  - Sun
exclude_addons: []
exclude_folders: []
backup_name: '{type} Snapshot (Samba Backup) {date}'

Any help is more than welcome.

This is a misunderstanding, the backup_name only controls the name of the snapshot which is for instance displayed at the Supervisor ā†’ Snapshots page. The filename itself comes from the slug which is the unique ID of each snapshot and cannot be controlled.

Are you using the Mosquitto broker addon? Does Samba Backup show you a warning in the logs after start?

1 Like