Wednesday, July 27, 2011

Lion, Time Machine and AFP feature bits.

Update2: SMB should be supported in _r2 version. Probably not a very good idea unless your network connection is solid. Also remember that you can't restore the whole system from a TM image on an SMB share.. at least not from OS X boot disk.
Update1: Please try updating your NAS firmware first; most manufacturers will be releasing updates that make their devices Lion-compatible in the near future.
These new flags made mandatory in Lion help with AFP session recovery after network connection loss, so you will be at a higher risk of data corruption when using this workaround over spotty WiFi.

'The network backup disk does not support the required AFP features' message means that
Lion's backupd now requires 'TM Lock Stealing' and 'Server Reply Cache' AFP features on all TM destinations.

TMShowUnsupportedNetworkVolumes workaround affects the UI but has no effect on actual daemon behaviour.
So, seeing as how I'm not going to buy a Time Capsule any time soon, an idea was born:
What if we could make backupd work with those unsupported volumes and unleash any potentially data-munching-monster-ish bugs this unsupportedness shall surely entail? Sounds like a plan!

tldr: Download, unzip and run the script.

^^ A dylib that fakes those new shiny AFP feature bits for your old musty half-dead early 20th century NAS-o-saurus.

Disclaimer: Use at your own risk; data-corru¾*{5Ë# may occur!

Boring tech details: just read the source.

74 comments:

Björn said...

hey, great to see you're working on that. but every time I run the script, "cannot execute binary file" appears. can you please help me. thanks for all!

msft.guy said...

@Björn: Please run the script in debug mode (bash -x ~/Downloads/backupd_anyafp/install.sh) and copy the output to http://pastie.org/, then post a link here..

Björn said...

YEEEHAAAAAA! I got it!!! Thanks so much!!! what a great day. thanks again ;) !!!!!

Unknown said...

it works great!!!

semi said...

Confirm from me too.. Works just fine. Now I can make timemachine backups from Lion to my Lacie Networkspace.

Also thanks goes to Google to rank this page so high, so soon :)

eli said...

I have a Terastation. I ran your script, but I am still not able to mount the Buffalo Terastation via AFP in Lion.

Any suggestions? Am I doing something wrong.

Thank you Very much.

msft.guy said...

@eli: Afaik there were two problems with Lion compat. The first was SMB1 support and 'DHCAST128' auth were disabled. Read here (http://charlestendell.com/os-x-lion-afp-nas-connection-error-fix/) on how to reenable them.
My post only pertains to the specific problem where you already _can_ mount your network drive via AFP or SMB, but Time Machine displays an error 'The network backup disk does not support the required AFP features'.
Hope this helps.

mattpreston said...

Glad I found your post, however I'm struggling to run the script? I ran this in terminal:

bash -x ~/Downloads/backupd_anyafp/install.sh

made sure all the paths were okay but then got your about about message..

TechWorldTips said...

Hello, also didn't work for me - http://pastie.org/2312673

All I did was drag the script to Terminal? Is that right?

msft.guy said...

@mattpreston: "but then got your about about message.." - can you elaborate on that? Or paste some Terminal output?..

@TechWorldTips: Script ran fine. Now start Console, filter for backup, then click 'Back Up Now' in TM menu; you should get some logs; copy them to pastie.org as well.
Were you getting 'The network backup disk does not support the required AFP features' message or something else?

woodstok said...

Just to clarify, should this work when using TM via SMB ? Doesn't work for me although script installs fine and did a reboot.

msft.guy said...

@woodstok: New version will work with SMB.. at least it works for me ;)
(Updated the post)
Post the Console log if it doesn't..

woodstok said...

Installed the current version and this makes a difference, but still no luck. See http://pastie.org/2313113. Am trying to backup to a previous image created under Snow Leopard (then and now via SMB).

msft.guy said...

@woodstok: the dylib works as expected, but TM can't create new images over SMB, and that's what it attempts to do according to the log.
Please try to mount the volume 'owl.sparsebundle' manually to verify it works and is writable.

woodstok said...

@mfst.guy, problem solved :-) TM now wanted the image at the top level of the mount point. Completed 11GB backup over WiFi. Works perfectly incld. restore. Can highly recomend this hack. Briliant, and thanks for sharing this!

Callum Catterall said...

@mfst.guy Hi, I've got it to backup, done a 58GB backup, and some others after it, can't seem to enter Time Machine, just says connecting to backup volume and then it goes?

Callum Catterall said...

@mfst.guy this is the console log, enter time machine shows up on my MacBook Pro, not the iMac - http://pastie.org/2317046

msft.guy said...

@Callum Catterall: Not sure what's wrong there... no errors and the backup volume seems to have been mounted OK. I think Finder does the TM UI, so no idea what goes wrong after backupd mounts the image; and I can't reproduce that myself (TM UI works for me over SMB), so good luck figuring this one out :/

Callum Catterall said...

@mfst.guy Nevermind, thanks for this though :)

RODVAL said...

Everything is working fine, but I cannot enter Time Machine to navigate through the hourly backups created. However I can see backups are done automatically. What could be wrong?

RODVAL said...

Here is the results... http://pastie.org/2342161

Ekynos said...

Works like a charm with my Buffalo Link Station WXL798. Thank you very much!

Woife said...

Perfect!!!

Works on a SMB-Share on WHS 2011.
Thanks alot.

Regards from Munich, Germany

Wolfgang

woodstok said...

Hi mfst.guy, backups and browsing TM have been working great. Backups do now (using SMB) take a lot longer than under Snow Leopard. There is an indexing-the-backup phase which I don't recall to have seen under Snow Loepard. This take a lot of time. Do you know if this is a Lion feature, or could this be a side effect of your sourcery ?

alexndr said...

How do I rollback the changes that the script makes?

minWi said...

You make my day! THANK YOU! :)

mixmax said...

@msft.guy
Trying to recover media from my iPhone2G 3.1.3 via SHH with RAMdisk method. I can't mount user data partition (getting invalid argument error) and can't fix it via fsck - see below:

-sh-4.0# fsck_hfs -r /dev/disk0s2
** /dev/rdisk0s2
** Checking Non-journaled HFS Plus volume.
** Detected a case-sensitive catalog.
** Checking Extents Overflow file.
** Checking Catalog file.
** Rebuilding Catalog B-tree.
** The volume Data could not be repaired.
-sh-4.0# fsck_hfs -p /dev/disk0s2
Invalid node structure
(4, 1582)

Any chance to access /dev/disk0s2 or dump raw contents of it via USB to host PC for further processing and recovery? Any other suggestions? %(

Blinde Kuh said...

You made a small error in the install.sh script. Nothing serious.

It should be:

sudo killall backupd 2>&1 >/dev/null

instead of

sudo killall backupd 2&>1 >/dev/null

Raffy said...

Cannot thank you enough for this work. I went around and around for *weeks* with numerous D-Link support forums, and command line AFP_DISABLED_UAMS prefs before trying your script to success. My DNS-323 now works with OSX Lion and Time Machine. Thanks again!

medic said...

Quick question concerning your disclaimer:

"Also remember that you can't restore the whole system from a TM image on an SMB share.. at least not from an OS X boot disk."

In case I want to restore it...how do it do it? Do I copy the TM image on a usb drive from my NAS and take it up from there or what would be the best way?

Thks

nerdy said...

could you help me with this one please?
http://pastie.org/2924446
Problem:"cannot execute binary fie"

apes said...

i think i love you. a while back i found out how to enable unsupported network disks and create a sparsebundle but it never would run the backup. it works now in Lion thanks to your script. i can breath now, so can my business... THANKS!

shortpitch said...

worked great on my MacMini with a DNS-323. Thanks!

albis said...
This comment has been removed by the author.
albis said...

Thanks thanks thanks thanks! I am finally able to use time machine to backup my macbook air and cisco x3000

seath2008 said...

On a BA4000 I keep getting this error from TM "The network backup disk does not support the required AFP features"

Any ideas?
Thanks!

seath2008 said...

wrong alert. everything works fine. I got the chicken answer first and I thought I was ok with installation (I typed the phrase with Capitals and Lows) just as it appeared and not in low letters
Anyway, after days of trials and errors and looking to install linux in BA it worked without all these tricks. Script was perfect

TechNazgul said...

Another thumbs up here. In my case I was mounting a Windows Server 2008 share to a MBP 13" via wireless and it worked fine.

Just to provide one other point to check if anyone is having problems... make sure you are only mounting via SMB, not NFS, which was how I started and that will not work. These were the first part of the instructions I followed to make the sparsebundle on the network share if anyone else needs them:

http://www.makeuseof.com/tag/backup-mac-homemade-time-capsule/

Thank you!

Mark said...

thank you! it worked great (once I had sorted out my administrator rights on my mbp). Buffalo Linkstation HS-DH500GL working with Time Machine & Lion. thanks again.

wuotr said...

So if I understand this correctly I have to run this script on my Macbook, which will enable me to connect with an SMB share? And then I'll have to create a .sparsebundle? Thanks in advance ;-)

msft.guy said...

@wuotr: just find an article describing how to set up TM to SMB in SL, now you can do the same stuff but in Lion, using this hack. I wouldn't know setup details anyway, since I already had a backup before my 10.6->10.7 upgrade.

wuotr said...

@msft.guy: Thanks for the info ;-)

One more (little) question though: What does the script actually do? Does it force Lion to use the DHCAST128 protocol instead of DHX2 when connecting to the SMB? Because I looked into the sourcecode, but I can't figure out how it works exactly :-S.

And can it be "undone"?

Thanks in advance (again).

msft.guy said...

@wuotr: To uninstall, go to /System/Library/LaunchDaemons/ and move com.apple.backupd.plist.bak to com.apple.backupd.plist.
Then you can remove the dylib from /usr/local/lib/..
It works by intercepting backupd's calls to fsctl() and returning stuff that makes backupd think AFP features are supported by the volume.

wuotr said...

@msft.guy: Allright! Thanks man ;-)

Steve said...

Witty install script... Time Machine working on my 'unsupported' SMB network drive for the first time since Lion. Thanks!

Alexander said...

It didn't work for me either. Tried to do backup - got the message "The network backup disk does not support the required AFP features." Here is the link http://pastie.org/2312673. Thanks much for your help

msft.guy said...

@Alexander: reboot, try to back up again, then start Console, select 'All Messages', type 'backup' into the Filter field, select all and post that too.

Alexander said...

Thanks for suggestions. After reboot and attempt to backup same message "The network backup disk does not support the required AFP features.

here is the Console "backup" results link http://pastie.org/3312446

msft.guy said...

@Alexander: fascinating.. looks like the dylib isn't getting loaded.

Copy following commands to Textedit/Terminal (don't type them manually if possible) to preserve line breaks and prevent typos

Try those commands (and pastie the output):
cat /System/Library/LaunchDaemons/com.apple.backupd.plist| grep -2 DYLD
cat /System/Library/LaunchDaemons/com.apple.backupd.plist| grep -1 Program
DYLD_INSERT_LIBRARIES=/usr/local/lib/libbackupd_anyfs.dylib /System/Library/CoreServices/backupd

Additionally,
Press 'Clear display' in Console, execute this command:
sudo bash -c "launchctl unload /System/Library/LaunchDaemons/com.apple.backupd.plist; launchctl load /System/Library/LaunchDaemons/com.apple.backupd.plist; launchctl start com.apple.backupd"
and copy the stuff that gets logged in Console.

Alexander said...

here is link to first set of commands http://pastie.org/3312626

console: http://pastie.org/3312653

msft.guy said...

@Alexander: Install didn't modify the files it was supposed to modify - make sure you're an admin etc.
e.g.:
sudo cp /Users/Callum/Downloads/backupd_anyafp/com.apple.backupd.plist /System/Library/LaunchDaemons/com.apple.backupd.plist

I can't figure out why things like 'sudo cp file dest' don't work on your machine, so you'll have to figure this out for yourself, sorry ;/

Alexander said...

Well, I followed your last suggestion, re-installed. Now, when I start TM it is sitting forever on "looking for backup disk". Sparsebundle is available and can be mounted manually, but that doesn't help... Any ideas? Thanks much.

msft.guy said...

@Alexander: Well, now it seems backupd crashes because you've changed the plist but didn't install the dylib.
Try these now:

sudo mkdir -p /usr/local/lib/
sudo cp ~/Downloads/backupd_anyafp/libbackupd_anyfs.dylib /usr/local/lib/

Alexander said...

Thank you SOOOO MUCH!!!! Backup started and going, probably will take some time... It's backing up to Buffalo LS-WTGL/R1-V3.

54fce6ca-51be-11e1-b694-000bcdcb5194 said...

Hello
on my iMac with 10.7.2 the directory /usr/local/lib does not exist! instead there is the directory /usr/lib

echo puts out to miss a few nuts and bolts ;-)
So what is missing?

msft.guy said...

@54fce6ca-51be-11e1-b694-000bcdcb5194: "nuts and bolts" error just means install script can't find other files from the zip; they all should be in the same directory after extraction. Care to post the verbose log? (run 'bash -x ~/Downloads/backupd_anyafp/install.sh')

54fce6ca-51be-11e1-b694-000bcdcb5194 said...

@msft.guy
thank you
I had find it out on myself also ;-) i have to fill in the base directory manually and then "run" the script command per command.
And its works with my Medion Life NAS ;-)
Thank you much.
:-Daniel

littlegti said...

Thank you so much for this. Just upgraded to Lion after testing everything else but TM. Not sure what I was thinking.

GhettoTimeCapsule said...

Use this to create sparse bundle on unsupported drive:

http://code.stephenmorley.org/articles/time-machine-on-a-network-drive/

Currently have 150 gb tm backup on a usb drive attached to a linksys wrt610n! Thanks!

GhettoTimeCapsule said...
This comment has been removed by the author.
BjörnD said...

Yeah, sooo f*cking great, even in 10.8! Thanks!

Papa Fink said...

Thanks for this, it is great. However, my Mac drive crashed and now have to restore from my smb backup on Win machine. How do I do it? Can't figure it out for the life of me.

snekiam said...
This comment has been removed by the author.
snekiam said...

Can somebody help me with this error message?

bash -x /Users/MYUSERNAME/Downloads/backupd_anyafp/install.sh
++ dirname /Users/MYUSERNAME/Downloads/backupd_anyafp/install.sh'
usage: dirname path
+ BASE=
+ check_my_stuff
+ test -f /libbackupd_anyfs.dylib -a -f /com.apple.backupd.plist
+ echo 'Seem to be missing a few nuts and bolts, ABORT, ABORT!!'
Seem to be missing a few nuts and bolts, ABORT, ABORT!!
+ exit 9001

Thank You!
-Snekiam

shound said...

great solution!!! finally lacie network work with TM!
thk a lot
(lion 10.7)

jus

wilcodis said...

Hey msft.guy, great script. It's just that TM fails to create the sparsebundle. When it first starts, I can see it creates a .tmp.sparsebundle but then it fails with error 45. See http://pastie.org/3903813. Any thoughts? Thanks!

Chris McGrew said...

@msft.guy,

I am having the same issues it not letting me back up due to the error of the disk not being afp. I have ran the your script and i also did the manual move of the files in your zip files to the locations you specified. and I am still getting the error. I have my NFS server mounted under the NFS share. any help will be most appreciated.

Chris McGrew said...

@msft.guy,

Thank you for the great script I got it to work after I manually created the sparsbundle using the hdiutil command and now it is working great.

THANK YOU, THANK YOU, THANK YOU!!!!!

osxwouteer said...

I still get the message saying the drive doesn't support the new afs encryption. is there anything I could do other than buying a time machine drive?

Deron said...

It worked very well for me for about 2 weeks, but then the 'integrity check' by Time Machine failed. I had to start over. It's working fine again, but now I'm not so sure I can trust this solution. Apple should make this easier. I don't want to plug in a USB drive to my laptop.

Shawn E. said...

Looks like another step for Mountain Lion is needed to make it work. The file updates. (com.apple.backupd), but Time Machine still won't see the network drive using SMB.

shound said...

your process was really great to use lacie with lion! just yesterday I upgrade to mountain lion...TM didn'tsee the smb NAS, so I repeat the procedure again, now it see the lacie but say me that the file sparsebundle...is alreadu in use!
what can I do?
thank so much for help

Liza Jenifer said...

I found this article very helpful, iPhone hacking is major issue now a day, I've got it to backup, done a 58GB backup, and some others after it, can't seem to enter Time Machine. more that there is an indexing-the-backup phase which I don't recall to have seen under Snow Loepard. This take a lot of time. you have done good job. Now I'm using Watch Phone but I want to buy iPhone, That's is main reason to search about iPhone.

Halman Freud said...

Yes, I have found and error, the same mistake I have made in my version of whatsapp for pc. but nothing bad. Congrats!