The Samba-Bugzilla – Bug 12380
vfs_fruit support for Time Machine over SMB
Last modified: 2017-02-18 23:53:55 UTC
Given that Apple has deprecated AFP for Time Machine backups in favor of SMB it would be beneficial to be able to use Samba to provide a network based backup destination.
Apple has published the required capabilities for supporting Time Machine backups over SMB and can be found here: https://developer.apple.com/library/content/releasenotes/NetworkingInternetWeb/Time_Machine_SMB_Spec/
Looking through the code I think this probably fits the best in vfs_fruit.c as that module handles a large amount of other integrations for Mac OSX.
I also have Wireshark captures of a working Time Machine backup to an OSX server and a non-working backup to a Samba server if that would be beneficial.
I started attempting to implement the required features but I would appreciate some help with some of the pieces.
I was able to change vfs_fruit to advertise the capability correctly but I can not determine if it is possible to flush the data when recieving an SMB2 FLUSH within the VFS layer. Is that possible?
Based on what I can find in the captures I believe that all of the other features are implemented already including SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 and SMB2_CREATE_REQUEST_LEASE_V2.
Please compress the pcap files with gzip --best and attach them to this bug report.
Attaching you work in progress patch would also help.
Here's some more stuff that nicely explains what F_FULLSYNC does on OS X:
I remember I simply faked this for Netatalk.
Ralph, please ping me about this requirement. I've been talking to Apple directly about this.
Created attachment 12576 [details]
Capture from a stock Samba 4.4.6 installation
Created attachment 12577 [details]
Capture from a Samba version running the attached patch for capabilities
Created attachment 12578 [details]
Capture from a working Mac OSX server providing Time capsule services
Created attachment 12579 [details]
WIP: Samba capabilities patch
This is a patch to advertise F_FULLSYNC to the client, but it does nothing beyond that at this time.
I was able to get the patch that I provided to work successfully for Time Machine backups. The reason that it was not working after applying the patch was due to not having durable file handles configured. After adding the following to my smb.conf file I was able to start a Time Machine backup.
- durable handles = yes
- kernel oplocks = no
- kernel share modes = no
- posix locking = no
After the backup I will attempt to restore a file to verify functionality. After reading what Ralph mentioned regarding the F_FULLSYNC fnctrl, my personal opinion is that it is OK to fake it like I did in the patch but I would certainly like some concurrence from others with more knowledge on Samba internals.
I did some more research on this and I believe that advertising the capability and taking no other action is an acceptable course of action. I went ahead and made it a configurable option, updated the man page, tested the code, and created a Github pull request for this issue. Here is the link to the PR: https://github.com/samba-team/samba/pull/64
Thanks for the patches and please keep pushing me to get them integrated. I need to discuss a few technical things with Jeremy related to this before I can start to do a review. So please stay tuned... :)
Thanks Ralph! I'll ping you in a week through this bug (if you prefer a different interval or communication method just let me know) for a status check/update. In the meantime if you think of anything that can be added or changed just let me know.
Have you had a chance to discuss this patch with Jeremy yet?
User ping on this. Should I go down the route of applying Kevin's patch for now or await a proper implementation of the feature? I have been planning to migrate to SMB-based Time Machine backups, but was sorely disappointed to find out about the new fruity extension. :(
The decision to apply it or not really depends on how much you want to trust your data to it. :) With that being said some changes are being discussed on the mailing list to ensure that backed up data is safe and consistent during events like power offs. I have been running the provided patch for my Mac's on a home server without any issues but it is also not my primary form of backups right now.