dianlight / hassio-addons

Hassio.io
MIT License
139 stars 48 forks source link

❓ [Samba NAS] Use an External SSD for Time Machine Backups? #226

Closed sayam93 closed 2 months ago

sayam93 commented 7 months ago

Addon

No response

Your request

Hi,

I have the latest Home Assistant OS running on my RPi 4B with Samba NAS add on installed. I have an external SSD connected (not mounted) to my Pi 4B on a USB 3.0 port with two ext4 partition, sdb1 (filesystem) and sdb2 (main storage). I want to be able to use the sdb2 partition connected to the Pi as a Network Time Machine Backup through Samba. I was earlier able to do this when I was running Raspberry Pi OS by mounting the drive (at /home/ex and made a folder named pibackup inside which served as target folder for backup) and edited the file smb.conf file at /etc/samba/ as follows.

Added:

**[global]**:

vfs objects = catia fruit streams_xattr

fruit:metadata = stream

fruit:model = MacSamba

fruit:posix_rename = yes

fruit:veto_appledouble = no

fruit:nfs_aces = no

fruit:wipe_intentionally_left_blank_rfork = yes

fruit:delete_empty_adfiles = yes

Edited:

[homes]
   comment = Home Directories
   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no (previously yes)

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0777 (previously 0700)

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0777 (previously 0700)

Ran the following commands to add password:

sudo smbpasswd -a pi
sudo systemctl enable smbd
sudo nano /etc/nsmb.conf

Added at the end to make it accessible directly in the file browser:


path = /home/ex/pibackup

writeable=Yes

create mask=0777

directory mask=0777

public=no

Since, I am new to Home Assistant OS, I am unable to replicate this. I have setup root SSH access using ‘HassOS SSH port 22222 Configurator’ add-on and also installed Samba NAS add-on. How do I accomplish this? Is there some smb.conf file installed by this addon that I can edit in a similar way?

Also, instructions to create an MQTT sensor to track the sdb2 disk usage would be really appreciated!

-Sayam

dianlight commented 7 months ago

Yon don'need. Read the documention.

sayam93 commented 7 months ago

Would the below config work for what I am trying to achieve?

workgroup: WORKGROUP
username: sayam
allow_hosts:
  - 10.0.0.0/8
  - 172.16.0.0/12
  - 192.168.0.0/16
  - 169.254.0.0/16
  - fe80::/10
  - fc00::/7
automount: true
moredisks:
  - sda2
mountoptions:
  - nosuid
  - relatime
  - noexec
available_disks_log: true
medialibrary:
  enable: false
veto_files:
  - ._*
  - .DS_Store
  - Thumbs.db
  - icon?
  - .Trashes
compatibility_mode: false
recyle_bin_enabled: false
wsdd2: false
mqtt_nexgen_entities: false
autodiscovery: {}
other_users: []
acl:
  - share: sdb2
    disabled: false
    timemachine: true
interfaces: []
password: password
mqtt_enable: true
mqtt_topic: sambanas

Also, the below in configuration.yaml is okay for mqtt sensor to track sda2 disk usage? (I have the Home Assistant Add-on: Mosquitto broker installed)

sensor:
  - platform: mqtt
    state_topic: "sambanas/sda2/status"
dianlight commented 7 months ago

The addon work with partitions labels and uuid not with block names. Sdb2 is a block name. If you are unsure try the automatic flag. Also Matt is automatic you don't need to configure anything, simple allow the ha auto discovery works. I suggest you to use mqtt_nextgen_entities.

L

sayam93 commented 6 months ago

The rest of the config looks fine?

dianlight commented 6 months ago

It is difficult, post the config and the startup logs with my proposed change and I can check.

L

Marty56 commented 4 months ago

Hi, I was delighted to see that it possible to create a samba server usable also for Time Machine backups. But I do really not understand the documentation. I would be great to post an example like the one above or to write a bit more in the documentation. Unfortunately it is also not clear for me whether this example above is working at all.

Marty56 commented 4 months ago

Hi i have the following setup. I created a folder unter "/mnt/data/supervisor/timemachine" and tried using this yaml setting. But it is not working. Any idea?

workgroup: WORKGROUP
username: homeassistant
password: mypassword
allow_hosts:
  - 10.0.0.0/8
  - 192.168.10.0/16
automount: true
moredisks: []
mountoptions:
  - nosuid
  - relatime
  - noexec
available_disks_log: true
medialibrary:
  enable: false
veto_files:
  - ._*
  - .DS_Store
  - Thumbs.db
  - icon?
  - .Trashes
compatibility_mode: false
recyle_bin_enabled: false
wsdd2: false
mqtt_nexgen_entities: false
autodiscovery: {}
other_users:
  - username: timemachine
    password: timemachine
acl:
  - share: timemachine
    disabled: false
    users:
      - timemachine
    timemachine: true
interfaces: []

logfile


 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-automount: starting
[15:27:17] INFO: Protection Mode is false
[15:27:17] INFO: MoreDisk or Automount option found!
modprobe: module ntfs3 not found in modules.dep
[15:27:17] WARNING: ntfs3 module not available!
modprobe: module exfat not found in modules.dep
[15:27:17] WARNING: exfat module not available!
modprobe: module xfs not found in modules.dep
[15:27:17] WARNING: xfs module not available!
---------------------------------------------------
Supported fs:   ext3    ext2    ext4    squashfs    vfat    msdos   iso9660 fuseblk btrfs
Supported fusefs: apfs  
---------------------------------------------------
[15:27:17] INFO: MediaLibrary disabled in config. Disk are mounted only for this addon!
---------------------------------------------------
[15:27:17] INFO: No Disk with labels.
---------------------------------------------------
[15:27:17] INFO: No MoreDisks to mount
s6-rc: info: service init-automount successfully started
s6-rc: info: service init-smartd: starting
s6-rc: info: service init-samba: starting
s6-rc: info: service hd-idle: starting
s6-rc: info: service hd-idle successfully started
[15:27:17] INFO: Hostname: homeassistant
[15:27:17] INFO: Interfaces: enp5s0 
[15:27:17] INFO: Enabling S.M.A.R.T for /dev/sda
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.6.33-haos] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

[15:27:17] INFO: Docker Interface: hassio 172.30.32.0/23
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
SMART Attribute Autosave Enabled.
SMART Automatic Timers not supported

SMART Automatic Offline Testing Enabled every four hours.

tdbsam_open: Converting version 0.0 database to version 4.0.
tdbsam_convert_backup: updated /var/lib/samba/private/passdb.tdb file.
s6-rc: info: service init-smartd successfully started
Added user homeassistant.
Added user timemachine.
---------------------------------------------------
[15:27:18] INFO: Exposed Disks Summary:
[CONFIG]                path = /homeassistant # TM:false#
[ADDONS]                path = /addons # TM:false#
[SSL]                   path = /ssl # TM:false#
[SHARE]                 path = /share # TM:false#
[BACKUP]                path = /backup # TM:false#
[MEDIA]                 path = /media # TM:false#
[ADDON_CONFIGS]         path = /addon_configs # TM:false#
---------------------------------------------------
s6-rc: info: service init-samba successfully started
s6-rc: info: service init-mqtt: starting
s6-rc: info: service wsdd: starting
s6-rc: info: service smbd: starting
s6-rc: info: service nmbd: starting
s6-rc: info: service avahi: starting
s6-rc: info: service wsdd successfully started
s6-rc: info: service smbd successfully started
s6-rc: info: service avahi successfully started
s6-rc: info: service nmbd successfully started
s6-rc: info: service cifs-supervisor-mount: starting
nmbd version 4.18.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2023
[15:27:18] INFO: Starting the AVAHI for homeassistant...
Waiting for daemon ...
s6-rc: info: service cifs-supervisor-mount successfully started
[15:27:18] INFO: MQTT support not enabled in config
s6-rc: info: service init-mqtt successfully started
s6-rc: info: service mqtt-disk-handler: starting
s6-rc: info: service mqtt-disk-handler successfully started
s6-rc: info: service mqtt-handler: starting
s6-rc: info: service mqtt-handler successfully started
s6-rc: info: service legacy-services: starting
[15:27:18] INFO: Starting the wsdd daemon for WORKGROUP/homeassistant...
smbd version 4.18.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2023
INFO: Profiling support unavailable in this build.
[15:27:18] INFO: Interfaces: -i enp5s0 
s6-rc: info: service legacy-services successfully started
2024-06-29 15:27:19,013:wsdd INFO(pid 334): using pre-defined UUID cb6a33a0-b841-531d-a34e-09ecec492eb1
2024-06-29 15:27:19,015:wsdd INFO(pid 334): joined multicast group 239.255.255.250 on 192.168.10.145%enp5s0
2024-06-29 15:27:19,019:wsdd INFO(pid 334): scheduling Hello message via enp5s0 to 239.255.255.250%enp5s0
2024-06-29 15:27:19,117:wsdd INFO(pid 334): joined multicast group [ff02::c] on fe80::6ba7:3760:d89d:27f5%enp5s0
2024-06-29 15:27:19,118:wsdd INFO(pid 334): scheduling Hello message via enp5s0 to ff02::c%enp5s0
*****

Samba name server HOMEASSISTANT is now a local master browser for workgroup WORKGROUP on subnet 172.30.32.1

*****
dianlight commented 4 months ago

You don't need to create folder or other manual modifications of the supervisor.

I'm sorry if the documentation is not clear but is a part time project for an advanced user that has the knowledge in Linux blocks devices, hassos internal functions and samba limit. Is not one of my target to make tutorials or support services.

The best I can do is summarize the steps:

L.

Marty56 commented 4 months ago

Hi dianlight, I could resolve the issue. Thanks for looking at my request. Timemachine is already making its first backup :-)

Thanks for your work and this great plugin!!

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.