Mac provides a built-in backup feature called Time Machine. Officially, the backup destination options include:
- External hard drives connected via USB, FireWire, or Thunderbolt.
- Network-based Time Capsule or macOS Server.
- External hard drives connected to an AirMac Extreme base station via USB.
In addition to these, it is possible to configure a Samba file-sharing server as a Time Machine backup destination.
A pre-existing Samba file-sharing server is required. If one is not set up yet, refer to this post for instructions on configuring a file-sharing server.
Creating a Backup Destination for Time Machine #
Execute the following commands to create the directory for Time Machine backups and assign ownership to the Samba user:
sudo mkdir -p /backup/timemachine
sudo chown mkt3:mkt3 /backup/timemachine
Configuring Samba for Time Machine #
Add the following configuration to /etc/samba/smb.conf
:
[global]
vfs objects = acl_xattr catia fruit streams_xattr
fruit:metadata = stream
fruit:encoding = native
[timemachine]
path = /backup/timemachine # Backup destination
valid users = mkt3 # Samba user
browsable = yes
writable = yes
fruit:time machine = yes
fruit:time machine max size = 256G # Maximum storage size for Time Machine
Restarting Samba Service #
Restart the Samba service with the following command:
sudo systemctl restart smb.service
This completes the setup of the Samba server for Time Machine.
Configuring macOS to Recognize the Time Machine Share #
To ensure macOS recognizes the Time Machine share, execute the following commands on the Mac:
sudo defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
sudo tmutil setdestination smb://"username":"password"@"server_ip"/timemachine
# Replace "username", "password", and "server_ip" accordingly.
# Example: smb://mkt3:[email protected]/timemachine
Initiating Time Machine Backup #
Open Menu
> System Preferences
> Time Machine
and click Select Disk
Choose the previously configured Samba share as the backup destination and click “Use Disk.”
This completes the Time Machine backup setup, and backups will be performed periodically.