Yes, it can. (I've been doing this for years.)
Types of disks you can use with Time Machine on Mac
On network volumes, TM backups are stored as sparsebundles.
Samba v4.8 or higher, has to be configured with macOS extensions, plus the share has to be configured for Time Machine.
Configure Samba to Work Better with Mac OS X
Depending on the host system, there might be a GUI (Synology DSM), otherwise Samba's smb.conf needs to be modified accordingly.
Yes, it can. (I've been doing this for years.)
Types of disks you can use with Time Machine on Mac
On network volumes, TM backups are stored as sparsebundles.
Samba v4.8 or higher, has to be configured with macOS extensions, plus the share has to be configured for Time Machine.
Configure Samba to Work Better with Mac OS X
Depending on the host system, there might be a GUI (Synology DSM), otherwise Samba's smb.conf needs to be modified accordingly.
Starting with macOS Tahoe, the AFS protocol for Time Machine is no longer accepted. One must use Samba with modern macOS for a homemade Time Machine.
At the time of writing, Tahoe is the latest macOS.
Install
samba. Make a groupsmbgroupand add a new user intended to only be used with the Samba connection:sudo groupadd smbgroupsudo useradd -M -s /usr/sbin/nologin timemachinesudo usermod -aG smbgroup timemachine
Set that new user's Samba password with
smbpasswdand enable the account:sudo smbpasswd -a timemachinesudo smbpasswd -e timemachine
Set up ACL support
sudo apt install acl(or equivalent for your package manager if not using a Debian-based distro)
Create the Time Machine directory. I keep it in
/srvas it's the idiomatic place to keep it on Linux.sudo mkdir -p /srv/timemachinesudo chown timemachine:smbgroup /srv/timemachinesudo chmod 2770 /srv/timemachine- We use 2770 rather than 770 because the 2 (setgid bit) ensures new files are owned by smbgroup.
Add ACLs
sudo setfacl -m group:smbgroup:rwx /srv/timemachinesudo setfacl -d -m group:smbgroup:rwx /srv/timemachine
There are several guides on how to configure smb.conf correctly for Time Machine. I will share my config below, just in case it helps. This is on Debian 13 and only serves macOS clients on Sequoia and Tahoe. I don't use Avahi/Zeroconf because the server remains connected around the clock without any issues.
[global]
server role = standalone server
workgroup = WORKGROUP
netbios name = fileserver
security = user
log file = /var/log/samba/log.%m
max log size = 1000
server min protocol = SMB3
client signing = required
obey pam restrictions = yes
pam password change = yes
unix password sync = yes
inherit acls = yes
map to guest = Bad User
vfs objects = catia fruit streams_xattr
fruit:metadata = stream
fruit:resource = stream
[TimeMachine]
path = /srv/time-machine
browsable = yes
read only = no
guest ok = no
valid users = @smbgroup
vfs objects = catia fruit streams_xattr
fruit:time machine = yes
fruit:model = TimeCapsule
fruit:metadata = stream
create mask = 0660
directory mask = 0770
Pro Tip: If making a fresh partition for Time Machine use, XFS is recommended more so than EXT4, because XFS is not susceptible to issues that could arise with an EXT4 FS, especially on larger drives. Basically, each file creates an inode for its metadata, but you have a limited number of inodes in ext4, whereas this isn't a problem that exists in XFS. This matters because Time Machine creates many very small files, so it would be possible to run out of inodes. This is what -T news exists for (the term is from news servers would would have many small text files). Formatting ext4 with -T news gives you more inodes if XFS isn't an option, so if you must use ext4, it would be recommended to format it with the news flag.
Backing Up macOS via Time Machine to a network SMB share
you can also use a synology device: https://www.synology.com/en-uk/knowledgebase/DSM/tutorial/Backup_Restore/How_to_back_up_files_from_Mac_to_Synology_NAS_with_Time_Machine
More on reddit.comAny Way to use a SMB Server for Time Machine?
Issues with TimeMachine / Samba on MacOS 13.2 Ventura
11.0.1 TimeMachine on Samba broken?
Videos
Is there a proper way to backup macOS via Time Machine to a network SMB share? I prefer to use a Windows share. If it's not possible, which OS would support Time Machine backup to a network SMB share?
Thank you.
EDIT I think I should clarify the things I have. So I have 1 Mac Mini with about 230GB used that's currently running Mojave that has APFS. I don't want to purchase additional hardware, because the hyperconverged 3-node cluster that I have has 40TB of usable space (about 1/3 of that space is used right now). With this hypercoverged 3-node cluster, I could use any Windows and Linux OS's. We set up data protection and it has its own node failover. I have a backup solution for this cluster as well. So basically, I would be backing up the Mac Mini on to a VM and then backing up the VM on to a backup drive.
I've set up the sparse bundle image and successfully backed it up via Time Machine on a Windows SMB share. Unfortunately, I was not able to restore the backup to a different Mac device that I'm testing right now.
I would like to know if there's an easier way to backup the Mac Mini without purchasing additional hardware.
Thanks again.
you can also use a synology device: https://www.synology.com/en-uk/knowledgebase/DSM/tutorial/Backup_Restore/How_to_back_up_files_from_Mac_to_Synology_NAS_with_Time_Machine
I spent a lot of time working on this. Basically, nope. I ended up with a virtual ubuntu box running netatalk (on hyper-v), but the share was still AFP. Scaled nicely with users, worked with quotas and AD. I've been told later version of time machine can use SMB shares (i did this 3 years ago) but haven't tested it myself. Reliability is the key. I've had marginal successes with SMB 3.0, but lots of failures where the entire backup needed to be redone. every month. which defeats the purpose of time machine, which is to allow time travel.
I have a 27" iMac (2020) and want to back it up with Time Machine. Recently I set up a NAS using a Raspberry Pi 4 and a 6TB WD Elements External HDD. Now I want to use this NAS as a Backup Server with Time Machine.
If I remember correctly, you create a TimeMachine Sparsebundle, mount it and set it as destination using "tmutil" in the Terminal. But every time I have done this, after a Week it would say to me that it needs to create a new Backup to enhance reliability or something.
So, my question is what I am doing wrong and if there is any way to prevent the Backup from corrupting?
I encountered the same issue, having my Mac refusing to create the initial sparse bundle files on my samba server. After incorporating the hints on https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X it finally started the backup.
Although I can only assume, the following comment caught my attention: How to store OS X metadata: fruit:metadata = stream
You could try switching from netatalk to stream. Maybe using netatalk prevents time machine from storing its metadata.
Good luck, Kay
Thought I'd post some additional info for people. My currently working smb.conf is as follows. Adding fruit:metadata = stream worked for only a short while for me, so below are the results of hours of additional testing.
Note this is on Debian 10 (Buster) so things like password change command will be different on other distributions. Also note that the order of modules in the setting vfs objects = catia fruit streams_xattr is significant and important.
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.
[global]
workgroup = WORKGROUP
min protocol = SMB2
log file = /var/log/samba/log.%m
max log size = 5000
logging = file
security = USER
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
username map = /etc/samba/users.map
map to guest = bad user
guest account = XXXYOURGUESTACCOUNT
# Time Machine settings
vfs objects = catia fruit streams_xattr
fruit:model = RackMac
fruit:advertise_fullsync = true
fruit:metadata = stream
fruit:veto_appledouble = no
#default is yes, not necessary to specify fruit:posix_rename = no
#default is yes, not necessary to specify fruit:zero_file_id = yes
fruit:wipe_intentionally_left_blank_rfork = yes
fruit:delete_empty_adfiles = yes
ea support = yes
#default is yes, not necessary to specify fruit:aapl = yes
# Make share visible to Windows
#Disabled for a Mac-Only network
# lanman auth = no
# ntlm auth = yes
# wins support = yes
# local master = yes
# preferred master = yes
# Allow symlinks
# follow symlinks = yes
# wide links = yes
# unix extensions = no
#======================= Share Definitions =======================
[SHARED DRIVE]
path = /PATH/TO/YOUR/SHARED/FOLDER
valid users = @YOURGUESTUSERGROUP
writable = yes
durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no
vfs objects = catia fruit streams_xattr
#default is yes, not necessary to specify ea support = yes
#default is yes, not necessary to specify browseable = yes
read only = no
inherit acls = yes
fruit:time machine = yes
fruit:metadata = stream
fruit:locking = netatalk
guest ok = yes
[Time Machine]
path = /PATH/TO/YOUR/SHARED/FOLDER
valid users = @YOURGUESTUSERGROUP
writable = yes
durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no
vfs objects = catia fruit streams_xattr
#default is yes, not necessary to specify ea support = yes
browseable = no
read only = no
inherit acls = yes
fruit:time machine = yes
fruit:metadata = stream
fruit:locking = netatalk
fruit:time machine max size = 1.9T
**EDIT: Turns out Samba 4.9 on Debian 10 DOES automatically advertise TimeMachine destinations, as long as there are no Samba-related advertisements in /etc/avahi/services. My system wasn't advertising the TimeMachine share because I also had a manual smb share setup for avahi. When I disabled BOTH, Samba properly advertised both.
*** OLD SEE ABOVE Also note that The Samba build with Debian 10 currently does not have built-in support for advertising Time Machine shares. Normally specifying fruit:time machine = yes will trigger Samba to advertise a Time Machine destination via Avahi, but this specific support is not built with the Samba included in Debian 10. You'll need to configure a .service definition in /etc/avahi/services/. I created time_machine_advert.service in that folder. You'll need to restart avahi to be sure it gets applied with sudo systemctl restart avahi. I have two Time Machine destinations. Multiples can be advertised within a single file by simply duplicating the txt record and incrementing dkX, i.e. dk1, dk2 etc.
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_adisk._tcp</type>
<txt-record>sys=waMa=0,adVF=0x100</txt-record>
<txt-record>dk0=adVN=SAMBA SHARE NAME EXACTLY,adVF=0x82</txt-record>
<txt-record>dk1=adVN=SAMBA SHARE NAME #2 EXACTLY,adVF=0x82</txt-record>
</service>
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>
There are some additional useful sites for Samba configuration with regards to Time Machine here:
Samba team's official guide to Time Machine configuration, although this alone didn't get a working config for me: https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X
smb.conf reference: https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html
vfs_fruit (the Apple compatibility module for Samba) reference https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html
Ken Murphy's smb.conf on GitHub that finally pushed me over the edge and got my setup working: https://github.com/KenMurphy/SambaConfigs/blob/master/smb.conf
A general Samba on Debian guide: https://www.antoneliasson.se/journal/time-machine-compatible-samba-on-debian-buster/