Skip to content

Restore your Mac favourite settings and software

Marco Massari Calderone edited this page Oct 5, 2020 · 4 revisions

Description

In case you have been playing with your Mac settings and have lost track of what and where you have applied changes, you can restore your favourite settings and applications on your current system.

For example, If you have messed with Homebrew:

  • you could run Splinter and let it fix the folder permissions

or remove the broken Homebrew directory and:

  • let Splinter reinstall it from scratch with all your desired Casks and packages

Prepare a restorable profile

You will prepare a profile with your favourite settings to be used in the future to restore your system preferences and user settings to your desired state.

This is a process to prepare a profile that will allow you to revert your preferred configurations on your running system in the future. If you want to reset your Mac follow the instructions to Rebuild a Mac to a clean state

Install Splinter in your Mac

Follow the installation instructions.

Configure your custom profiles

In ./splinter/profiles/ you will find the base profile that you will customise to your needs.

The base profile includes the full set of configuration files with the full set of configuration attributes set the most common desired values.

Each module has its own configuration file with its own attributes and toggles that you can customise.

    base profiles structure

    profiles/
    └── base
        ├── current_user.yml
        ├── dotfiles.yml
        ├── extra_packages.yml
        ├── filevault_option.yml
        ├── homebrew.yml
        ├── mac_app_store.yml
        ├── macos_apps_list.yml
        ├── modules.yml
        ├── new_user.yml
        ├── post_provision.yml
        ├── sophos-endpoint.yml
        ├── ssh_config.yml
        └── system_preferences.yml

Set system preferences

All modules are disabled by default, you will need to:

  1. Enable the modules for which you want to run the provisioning:

     # file: ./profiles/base/modules.yml
    
     configure_filevault:       no # Activate FileVault2, fine-tuning in filevault_options.yml
     configure_sophos_endpoint: no  # Install Sophos Endpoint from your organisation
     configure_homebrew:        yes # Install and Configure Homebrew to be used by all accounts
     configure_system:          no  # Set default settings for the operating system, fine-tuning in osx_config.yml
     configure_dotfiles:        yes # Import your exported dotfiles (explained below)
     configure_extra_packages:  yes  # you will restore your system preferences from and export of your current settings
     configure_setapp:          no  # Install SetApp application store and launch it, you will to sing-in and download your favourites manually from the app
     install_mas_apps:          yes # Install apps from Mac App Store
     install_macos_apps:        yes # Install apps from direct links: apps not available in Mac App Store or as a Homebrew Cask
    

    Set configure_system: no because you will restore your system preferences from and export of your current settings

  2. Define the sources of your system preference:

    a. manually set your desired preferences:

    • set configure_system: yes in ./profiles/base/modules.yml
    • and define your preferences in ./profiles/base/system_preferences.yml

    This option will restore your system preferences according a tailored list of attributes that you will manually set in system_preferences.yml

    b. Alternatively enable the restoration of you exported dotfiles and configurations

     # file: <base_profile>/dotfiles.yml
    
     restore_preferences_and_dotfiles_from_export: no
    

    This option will restore your system preferences according to the export/snapshot of the system settings you have currently set

Export your current system preferences and dotfiles and app lists

In case you have optionf to enable the restoration of you exported dotfiles and configurations:

./splinter export all

This command will export to ./files/lists and ./files/preferences the following files (if you have any of these subsystems installed):

files/preferences         # your system preferences
                          # your application settings
                          # Dock and menu bar settings
                          # your Internet Accounts registered in System Preferences (iCloud, Google Accounts, etc.)
                          # all the dotfiles in your home dir                            
                          # and anything that Macprefs tool can backup (https://github.com/clintmod/macprefs)

homebrew_taps.txt         # list of brew taps, packages and cask formulas
homebrew_cask_apps.txt
homebrew_packages.txt

ruby_gems.json            # list of user-installed Ruby gems
mas_apps.txt              # list of installed apps from MacAppStore
npm_global_packages.json  # list of NPM packages
pip_packages.json         # list of user-installed Python packages from Pip

These files will be used by Splinter to reinstall the same set of packages and apps

Most probably not all your applications are installed via MacAppStore or Homebrew Cask. We can fix that!

You can browse the list of applications available as Hombrew Cask formula and add your favourite applications to homebrew_cask_apps.txt.

This will automate the installation of your favourite apps

Create your list of non-MAS and non-Cask Applications

You can configure a list of application for which you want to automate the installation even if they are not present in the Mac App Store or as a Homebrew Cask.

you can edit that list in

# file: <custom_role>/macos_apps.yml

macos_apps_install_list:
    - { u: 'https://central.github.com/deployments/desktop/desktop/latest/darwin',
        f: 'GitHubDesktop.zip',
        n: 'GitHub Desktop',
        t: 'zip',
      }
    - ....

To be honest, this is not the most straight forward system so I advise reading the documentation in the GitHub documentation from the developer of the ansible-macos-apps-install Ansible role

Save your profile to a safe location

Now that you have customised your base profile and maybe exported your current system preferences, dotfiles and user configurations

Save the ./files and ./profiles directories to a safe place: Google Drive, Dropbox or a USB drive to be used the day you want to restore them.

Alternatively you could also choose to create a provisioning package with

./splinter create package

This command will create a self-contained DMG file with all the Splinter dependencies. Store the SplinterProvision.dmg package in a safe storage.

Restore you Mac with your custom profile

The day you want to restore you configurations

Add the Terminal application (located in /Applications/Utilities/) to the "Full Disk Access" policy

  1. Open System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
  2. Authenticate to unlock the list of allowed applications
  3. Add Terminal to the list of allowed apps, save and close.

install Splinter( if it is not installed already) and copy the previously saved ./files and ./profiles directories into the splinter directory. The run the provisioning to restore your settings.

./splinter provision

In case you have previously opted for the creation of a provisioning package

  1. copy the SplinterProvision.dmg file to your drive (from your safe storage)

  2. mount it double-clicking on it

  3. from the Terminal application

    cd /Volumes/SplinterProvision
    
    # run the provisioning
    ./splinter provision