Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created December 16, 2019 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomykaira/d9ea6edb67ddb085dd33358b99008718 to your computer and use it in GitHub Desktop.
Save tomykaira/d9ea6edb67ddb085dd33358b99008718 to your computer and use it in GitHub Desktop.
How to set up TimeMachine drive on your NAS (but inefficient, slow).
  • Login to your SMB with Finder, and save the password to Keychain.
  • Create timemachine-macbook.sparsebundle under the SMB root directory.
  • Mount it to /Volumes/TimeMachine.
  • Run tmutil setdestination /Volumes/TimeMachine as root (with sudo).
  • Allow security command to access your keyring to automate mounting TimeMachine drive.
    • security find-generic-password -wa TimeMachineSparseBundlePass
    • security find-internet-password -ws ***SMB HOSTNAME***
    • If you are prompted, always allow security to access these passwords.
  • Save the attached mounttm.plist and mkmountpoint.plist to local.
  • Rename ***xxx*** points according to your environment.
  • Place mkmountpoint.plist at /Library/LaunchDaemons/mkmountpoint.plist.
    • This file creates mount point for SMB under /Volumes.
    • Execution of this command requires root permission.
  • Place mounttm.plist at ~/Library/LaunchAgents/mounttm.plist.
    • This file creates mount point for SMB under /Volumes.
    • Execution of this command requires root permission.
  • Reboot the machine and check everything works.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.tomykaira.mkmountpoint</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>mkdir -p /Volumes/timemachine-smb && chown ***YOUR MAC USER NAME*** /Volumes/timemachine-smb</string>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.tomykaira.mounttm</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>mount_smbfs "//***Windows UserName***:$(security find-internet-password -ws ***HOSTNAME***)@***HOSTNAME***/***FOLDER NAME***" /Volumes/timemachine-smb && printf '%s\0' "$(security find-generic-password -wa TimeMachineSparseBundlePass)" | hdiutil attach -encryption AES-128 -stdinpass -mountpoint /Volumes/TimeMachine /Volumes/timemachine-smb/timemachine-macbook.sparsebundle</string>
</array>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment