Samba Backup: Create and store backups on a Samba share

Thanks for this addon.
Could you add an md5 checksum to the backupped file?

Is it possible to create a file size sensor of the latest backup file which updates after every backup?

Hi Thomas, this is a wonderful addon, thanks a lot for the effort and maintenance.
One question in regards to a full SD card backup. Is this something you plan on adding anytime soon?

Does Samba Backup create the backup file n HA, then copy it to the share after completion, or is it concurrent?

As I know samba backup creates backup file and than copy it to the share. If copy fail, backup file remain in backup directory.

Hi guys, sorry for the maybe the stupid question :slight_smile: ā€¦I installed samba backup and configuring the automatich backup in a qnap nas. The nas name is QNAP and would like to store backup in this path
\QNAP\Personal\Server\Home Assistant\Backup.
Is it correct if i configure like this:
share : QNAP
target directory: Personal\Server\Home Assistant\Backup
?

Solved
Host : ā€œmy ip addressā€
Share : Personal
target directory: \Server\Home Assistant\Backup

1 Like

Thank you very much for this! It is extremely helpful to me and allow me to finally automate this taskā€¦

Hi, new user here to this add on. For the life of me I canā€™t get it going ā€“ it keeps saying that the target directory doesnā€™t exist and Iā€™ve tried various entries based on this thread - i.e. \server\share\folder, just ā€œfolderā€, \server\share\folder, /folder, /folder/, Folder, and other things.

Itā€™s just not getting started. I did notice something weird: if my folder starts with a lowercase letter the addon cuts off the first letter. For example:

[23-01-19 07:40:04] INFO: Target directory: backups
[23-01-19 07:40:04] INFO: ---------------------------------------------------
[23-01-19 07:40:05] WARNING: cd ackups\: NT_STATUS_ACCESS_DENIED
[23-01-19 07:40:05] FATAL: Target directory does not exist. Please check your config.

But with a capital first letter:

[23-01-19 07:41:54] INFO: Target directory: Backups
[23-01-19 07:41:54] INFO: ---------------------------------------------------
[23-01-19 07:41:55] WARNING: cd \Backups\: NT_STATUS_ACCESS_DENIED
[23-01-19 07:41:55] FATAL: Target directory does not exist. Please check your config.

In any case I canā€™t get it configured regardless, and it seems like the backup folder is required (Iā€™m happy to just drop files into the root directory of the share but that doesnā€™t seem possible).

Any tips would be greatly appreciated!

Hereā€™s the other info from the log:

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 6.6  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2023.1.4
 Home Assistant Supervisor: 2022.12.1
-----------------------------------------------------------

If you had send your configuration and the serverdata (name, share, folder) someone could have answered you.
Home Assistant is running on a *nix system, so the character to divide folders is ā€ž/ā€œ. The backslash is only used in Windows systems.

I understand the differences with slashes. Hereā€™s the rest of my config although I thought what I shared was enough to help figure out whatā€™s going on:

host: <IP of NAS>
share: HomeAssistant
target_dir: Backups
username: homeassistant
password: <password>
keep_local: "4"
keep_remote: all
trigger_time: "03:30"
trigger_days:
  - Mon
  - Wed
  - Fri
  - Sat
  - Sun
exclude_addons: []
exclude_folders: []

For the target_dir ā€“ are ANY slashes required for some reason? The Backups folder is at the root level on the samba share.

This is interesting ā€“ not sure why itā€™s changing the slashes from what I specified ā€œ/Backupsā€ to something with backslashes:

[23-01-19 10:20:05] INFO: ---------------------------------------------------
[23-01-19 10:20:05] INFO: Host/Share: <IP of NAS>/HomeAssistant
[23-01-19 10:20:05] INFO: Target directory: /Backups    <----- my config
[23-01-19 10:20:05] INFO: Keep local/remote: 4/all
[23-01-19 10:20:05] INFO: Trigger time: 03:30
[23-01-19 10:20:05] INFO: Trigger days: Mon Wed Fri Sat Sun
[23-01-19 10:20:05] INFO: ---------------------------------------------------
[23-01-19 10:20:07] WARNING: cd \Backups\: NT_STATUS_ACCESS_DENIED      <------ WTF?
[23-01-19 10:20:07] FATAL: Target directory does not exist. Please check your config.

Wow, this seems to be strange behavior. Not sure why the \033[0m shows upā€¦

config:

share: HomeAssistant
target_dir: \Backups\
username: homeassistant

log:

[23-01-19 10:24:26] INFO: Target directory: \Backups\033[0m
[23-01-19 10:24:26] INFO: Keep local/remote: 4/all
[23-01-19 10:24:26] INFO: Trigger time: 03:30
[23-01-19 10:24:26] INFO: Trigger days: Mon Wed Fri Sat Sun
[23-01-19 10:24:27] INFO: ---------------------------------------------------
[23-01-19 10:24:28] WARNING: cd \Backups\: NT_STATUS_ACCESS_DENIED

One last thing, the docs state this:

Option: target_dir

The target directory on the Samba share in which the backups will be stored. If not specified the backups will be stored in the root directory.

But you canā€™t leave it out. Leaving the ā€œtarget_dir:ā€ with nothing or taking it out all together errors out:

Failed to save add-on configuration, Missing option 'target_dir' in root in Samba Backup (15d21743_samba_backup)

This is my configuration (you can also write your interal IP addresses here, as no one can reach them):

and this is the log:

So the ā€žnormalā€œ path to the folder (this can directly be used eg. on a Mac) would look like that:
smb://192.168.178.101/HA-Backup/Pi4

I donā€˜t know if lower and uppercase is important, but maybe it is.

Are you sure you have the correct rights set for the user ā€žhomeassistantā€œ with the specified password for the share itself and also for the folder you are using?

Fix the slashes, set them as the forward /

Check your user on the Backup Device is called ā€œhomeassitantā€ and they have full write access to that folder. Not just share access, but write access at a file level too.

With those NT errors, I assume your samba share is on a Windows machine. Right Click your shared folder and make sure the Security tab has write permissions for the user ā€œhomeassitantā€. You need write permissions on both the Sharing tab and the Security tab.

Your settings show this is the full path. Capitals are important and must match.
//ipaddress/HomeAssitant/Backups/

OK, I finally got this working by using just a ā€œ/ā€ as the target_dir and it drops files into the top level folder of the share. Not sure why none of the other attempts worked (I tried various forward/back slashes, etc) and also noticed that it was ā€œescapingā€ some things, i.e. /backups was escaped as ā€œ/bā€ and then ā€œackupā€ - not sure how I could control that behavior. Double slashes didnā€™t seem to help either.

But in any case, Iā€™m going to leave it as is dropping into the top level with just ā€œ/ā€.

Thanks for the help!

Hello and thanks for a splendid add-on.

I am struggling a bit and am hoping someone might recognise an error message at lines 14 and 15 of precheck.sh - I have read the thread looking for mention of it and cannot see it.

[23-01-22 16:11:24] INFO: ---------------------------------------------------
[23-01-22 16:11:24] INFO: Host/Share: SYNOLOGYRACK/RaspberryBackups
[23-01-22 16:11:24] INFO: Target directory: raspberryHome
[23-01-22 16:11:24] INFO: Keep local/remote: all/all
[23-01-22 16:11:24] INFO: Trigger time: 12:53
[23-01-22 16:11:24] INFO: Trigger days: Mon Tue Wed Thu Fri Sat Sun
[23-01-22 16:11:24] INFO: ---------------------------------------------------
[23-01-22 16:11:25] DEBUG: Backups local/remote: 22/0
[23-01-22 16:11:25] DEBUG: Total backups succeeded/failed: 0/1
[23-01-22 16:11:25] DEBUG: Last backup: never
scripts/precheck.sh: eval: line 14: unexpected EOF while looking for matching ``'
scripts/precheck.sh: eval: line 15: syntax error: unexpected end of file
[23-01-22 16:11:25] WARNING: 
[23-01-22 16:11:25] FATAL: Cannot access share. Unknown reason.
[23-01-22 16:11:25] DEBUG: Posting sensor data to API at /core/api/states/sensor.samba_backup
[23-01-22 16:11:25] DEBUG: API Status: 200

Kind thoughts,

Andrew

Is your sensor available? When your NAS was not accessible at boot-time of your HA instance the sensor will not be initiated. A reboot of your HA server/hardware should solve this if the NAS is accessible at boot time.

Do you have made a automation to restore the sensor on startup of HA?

Hello, and thank you @Janneman and @BebeMischa for looking at this - it turns out that having a password with a single quotation mark in it is a no no, causing precheck to fail immediately.

I also needed to use an ip address rather than the server name.

And it works.

Kind thoughts,

Andrew

1 Like