A New Way of Backing Up Data for My MacBook Pro
My faithful external hard disk drive finally stopped functioning after years of flawless service.
For years and across 2 different Macbook Pros, I used an external hard drive to store my Time Machine backups. Years ago I purchased an Oyen Digital Minipro 1TB hard disk drive (HDD). It has a USB-C interface with USB3.1 specifications. For many years this device served my former Macbook Pro (MBP) 16-inch Gen-1 Touchbar PC and the current 14-inch MacBook Pro M3 PC faithfully with zero issues. However, about 2 months ago this soldier started to show its age.
One night I attempted a Time Machine backup as usual, but this time was very different. After connecting the external HDD to the PC I noticed the desktop icon for the external HDD would quickly appear on the desktop then disappear. Additionally, I heard a very familiar repeated clicking sound coming from the external HDD that meant only one thing: The drive was cooked. The likely cause was the accumulation of bad sectors on the HDD finally taking its toll. I needed a solution soon and as luck would have it I did not have to look far.
I had a “decommissioned” Linux tower PC that I planned to turn into a home server but was dragging my feet on the task. It has 32GB of RAM and 9.256TB of storage across four storage mediums; 2 HDDs (4TB each) and 2 SSDs (256GB and 1TB). I realized Debian server could be setup on the tower PC and I could designate the 1TB SSD as a network drive location for the MBP’s Time Machine backups. Using the loss of my external HDD as motivation, I setup Debian Server 13.7.0 on the tower PC and attempted to setup Samba but ran into issues as the setup I found online was not complete enough.
The following steps are the cleaned-up version of what I was able to cobble together to get a TimeMachine-compatible network drive working on Debian server for my MBP, using an online guide I found for Samba and asking questions to Ask Brave A.I.
1. Update Samba
echo "deb http://deb.debian.org/debian trixie-backports main" | sudo tee /etc/apt/sources.list.d/backports.list
sudo apt update
sudo apt install -t trixie-backports samba samba-common-bin samba-ad-dc winbind smbclient cifs-utils
sudo smbd --version, result: Version 4.24.7-Debian-4.24.7+dfsg-1~bpo13+1
2. Installed addition Samba-related items
sudo apt install samba-vfs-modules avahi-daemon
3. Create the Samba group if it does not exist
sudo groupadd sambashare
4. Create these variables in the terminal
export SAMBA_USER=<some username>
export SAMBA_PASSWORD=<some password>
5. Create a Samba user with the following commands
useradd -M -s /usr/sbin/nologin -G sambashare "${SAMBA_USER}"
printf '%s\n%s\n' "${SAMBA_PASS}" "${SAMBA_PASS}" | sudo smbpasswd -s -a "${SAMBA_USER}"
sudo pdbedit -L
testparm -s
6. Add the target drive as an entry to the ‘/etc/fstab’ file and reboot the system. I set the mount location to ‘/mnt/<DRIVE_NAME>’
<USERNAME>@<HOSTNAME>:~$ vim /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdd2 during installation
UUID=<SOME_UUID> / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sdd1 during installation
UUID=<USB_ID> /boot/efi vfat umask=0077 0 1
# swap was on /dev/sdd3 during installation
UUID=<SOME_UUID> none swap sw 0 0
# HERE -> network drive for Samba and Time Machine backups
/dev/disk/by-uuid/<SOME_UUID> /mnt/<DRIVE_NAME> auto nosuid,nodev,nofail,x-gvfs-show 0 0
7. Change the ownership for the target drive
sudo chmod -R root:sambashare /mnt/<DRIVE_NAME>
8. I added the following content to the Samba configuration file ‘/etc/samba/smb.conf’:
[global]
# Apple/Time Machine support โ all fruit settings go in [global]
vfs objects = catia fruit streams_xattr
fruit:metadata = stream
fruit:aapl = yes
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
# ...
[ShareDrive]
path = /mnt/<DRIVE_NAME>
fruit:time machine = yes
browseable = yes
read only = no
create mask = 0664
directory mask = 2775
valid users = @sambashare
9. Created the ‘/etc/avahi/services/timemachine.service’ file and put in the following content:
<?xml version="1.0" standalone='no'?>
<group name="timemachine">
<service>
<name>TimeMachine</name>
<type>_smb._tcp</type>
<port>445</port>
</service>
<service>
<name>TimeMachine</name>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
<service>
<name>TimeMachine</name>
<type>_adisk._tcp</type>
<port>9</port>
<txt-record>sys=adVF=0x100</txt-record>
<txt-record>dk0=adVN=ShareDrive,adVF=0x82</txt-record>
</service>
</group>
10. Restart the relevent daemons:
sudo systemctl restart smbd nmbd avahi-daemon
11. Extra and very much needed: Prevent the server from suspending or sleeping
sudo tee /etc/systemd/sleep.conf.d/nosuspend.conf << 'EOF'
[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no
EOF
In macOS, I did the following:
- open a Finder window
- Press
[Ctrl] + K - Enter the following URL:
smb://<SERVER_IP_ADDRESS>/<SHARE_DRIVE_NAME> - Press ‘connect’
- Open the Settings application
- Navigate to ๐๏ธ General ๐๏ธ Time Machine
- Click ‘add drive’
- Select the Samba shared drive
- When prompted, enter the Samba username and password
Once finished a drive icon appeared on the macOS desktop and I was able to perform a manual Time Machine backup over the home network to the Linux home server. I greatly credit Mr. Oteyo and Ask Brave A.I., without them the Samba network drive and share would not have happened in a reasonable timeline.