A tool to backup and restore Mac preferences.
This will backup and restore Application as well as System Preferences.
I wanted a solution to back up my settings for my Mac and one didn't really exist. Time Machine is a bit overkill for this.
At first I was trying to create a bash script to restore all my settings. I was trying to adapt the ~~.osx~~ .macos file from Mathias Bynens. I noticed that some of the cases for the domains were wrong/outdated and weren't actually changing the preferences they were intended to change.
Running defaults write with the wrong case for the keys or domains also causes problems as the defaults command may fail silently.
Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install clintmod/formulas/macprefs
You can set the MACPREFS_BACKUP_DIR environment variable to specify where you'd like to backup the prefs too.
The default backup directory is ~/Dropbox/MacPrefsBackup.
export MACPREFS_BACKUP_DIR="$HOME/SomeOtherDir"
You can backup your preferences by running:
macprefs backup
You can restore your preferences by running:
macprefs restore
# grant admin group read on ~/Dropbox
chmod +a "group:admin allow list,search,readattr,readextattr,readsecurity" ~/Dropbox/
# grant admin group read on ~/Dropbox/MacPrefsBackup recursively (-R)
chmod -R +a "group:admin allow list,search,readattr,readextattr,readsecurity" ~/Dropbox/MacPrefsBackup
# grant dir list (execute) permission on all subfolders of ~/Dropbox recursively (-R)
chmod -R +X ~/Dropbox
# remove execute permission for other on all files and folders because
# +X adds other permissions
chmod -R o=-x ~/Dropbox
~/Library/Preferences and /Library/Preferences~/Library/Application Support/com.apple.sharedfilelist/Library/LaunchAgents, /Library/LaunchDaemons, ~/Library/LaunchAgentsThese scripts makes copies of plist files in ~/Library/Preferences and is not compatible with the way Mackup creates symlinks for some of these files. On the bright side though, if you use this as well as Mackup to backup and restore, everything should just work. Just remember that any preferences Mackup backs up won't be backed up by this tool.
defaults writedefaults write and use the wrong/old case for the domain you can create a new plist file with the wrong case (e.g. com.apple.addressbook instead of com.apple.AddressBook).defaults app has a tendency to fail silently for some things. You might be trying to use old defaults write commands where the key is the wrong name.defaults write commands in bash script can be error prone and the defaults command will fail silently./Library/Preferences (e.g. PowerManagement)~/Library/Application Support/com.apple.sharedfilelist/Library/LaunchAgents, /Library/LaunchDaemons, ~/Library/LaunchAgentsbash script of defaults write commands by diffing a new user account against the owned accountpip install -r requirements.txtmake test lint (make sure you've done the Getting Started)$ claude mcp add macprefs \
-- python -m otcore.mcp_server <graph>