Skip to content

Instantly share code, notes, and snippets.

@jdwoody
Created February 9, 2022 16:41
Show Gist options
  • Save jdwoody/ca661505ae67f284374f8b5cd0a1e1ab to your computer and use it in GitHub Desktop.
Save jdwoody/ca661505ae67f284374f8b5cd0a1e1ab to your computer and use it in GitHub Desktop.
macOS Time Machine backups to SmartOS SMB
#!/bin/bash
# I generally run this one command at a time, script format is for syntax highlights
# Tested personally with macOS Big Sur on Intel mac, use at your own risk, zero warranty
# Requires delegate dataset, refer to tm.json zone config. Uses base-64-lts, 21.4.0
#
# References:
# Respect to Brian Bennett @ Joyent
# https://datasets.at - zone generation
# https://illumos.topicbox.com/groups/discuss/T97ac7717dd31b5b5-Mb58fec102ab950b3bbc54843 - smb support thread
# https://wiki.smartos.org/configuring-smb-in-smartos/ - smb guide for SmartOS
export SMB_USER="yourUserName"
pkgin update
pkgin -y upgrade
pkgin -y install avahi
#edit /etc/pam.conf for pam_smb_passwd TODO convert to echo >>
# add the following, not that tabs, "\t", are required between the values:
# other password required pam_smb_passwd.so.1 nowarn
vi /etc/pam.conf
svcadm enable smb/server
svcadm enable smb/client
svcadm enable rpc/bind
svcadm enable idmap
useradd ${SMB_USER}
passwd ${SMB_USER}
zfs create zones/$(zonename)/data/backup && zfs set mountpoint=/backup zones/$(zonename)/data/backup
chown ${SMB_USER}:other /backup
sharemgr add-share -r tm-backup -s /backup smb
cat <<-EOF > /opt/local/etc/avahi/services/smb.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<!--
BASH commands that mimic this config
dns-sd -R "hostname" _device-info._tcp. local 445 model=Xserve &
dns-sd -R "hostname" _smb._tcp. local. 445 &
dns-sd -R "hostname" _adisk._tcp local sys=waMa=0,adVF=0x100 &
dns-sd -R "hostname" _adisk._tcp local dk0=adVN=timemachine,adVF=0x82 &
-->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_device-info._tcp</type>
<port>445</port>
<txt-record>model=Xserve</txt-record>
</service>
<service>
<type>_adisk._tcp</type>
<port>445</port>
<txt-record>sys=waMa=0,adVF=0x100</txt-record>
<txt-record>dk0=adVN=tm-backup,adVF=0x82</txt-record>
</service>
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>
EOF
svcadm enable -r svc:/pkgsrc/avahi
{
"brand": "joyent",
"image_uuid": "c8715b60-7e98-11ec-82d1-03d16599f529",
"autoboot": true,
"alias": "timemachine",
"hostname": "timemachine",
"delegate_dataset": true,
"resolvers": [
""
],
"max_physical_memory": 512,
"max_swap": 512,
"quota": 2048,
"nics": [
{
"nic_tag": "YOUR_NIC_TAG",
"mac": "00:00:00:00:00:00",
"ip": "dhcp"
}
],
"customer_metadata": {
"root_authorized_keys": "YOUR SSH KEY"
},
"internal_metadata": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment