Home

Awesome

Mac Preferences Backup

A tool to backup and restore Mac preferences.

This will backup and restore Application as well as System Preferences.

Motivation (.macos problems)

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.

Requirements

Installation

Install Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install clintmod/formulas/macprefs

Config

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"

Backing Up

You can backup your preferences by running:

macprefs backup

You can also choose to backup selected preferences by running:

macprefs backup -t system_preferences startup_items preferences app_store_preferences internet_accounts

Following backups are currently possible:

system_preferences : Backs up /Library/Preferences/com.apple.PowerManagement.plist or /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist, depending on the availability.

startup_items : Backs up user launch agents, system launch agents and system daemon agents

dotfiles : Backs up all your dotfiles from your home directory.

shared_file_lists : Backs up ~/Library/Application Support/com.apple.sharedfilelist/

preferences : Backs up ~/Library/Preferences/

app_store_preferences : Backs up your App Store preferences

internet_accounts : Backs up your ~/Library/Accounts

Note:

Make sure you have given full disk access to your terminal app for this script to work properly. You can run this command to open system preference window

open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"

Restoring

You can restore your preferences by running:

macprefs restore

Similar to Backing, you can choose to restore selected preferences by running

macprefs restore -t system_preferences startup_items preferences app_store_preferences internet_accounts

Testing the 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

What it Does

Notes

Todo

Problems

Contributing

Getting started

Running the tests

Getting your changes merged