Skip to content

Instantly share code, notes, and snippets.

@fiedl
Last active November 8, 2016 15:59
Show Gist options
  • Save fiedl/3e8e06889029d9544e35c689700629ba to your computer and use it in GitHub Desktop.
Save fiedl/3e8e06889029d9544e35c689700629ba to your computer and use it in GitHub Desktop.
macOS Calendar & Address Book Server: Reset

Issue

  • I cannot sync my contacts with macOS Server anymore.
  • pythonwrapper cpu usage is high.
  • "Unable to verify account or password."
  • There are hundreds of addressbook groups called "addressbook".

Resolution

Attention: This will only backup the calendar and addressbook data. If you use other macOS server services, make sure to backup their data as well!

  • brew uninstall postgresql.
  • Backup calendar and addressbook data.
  • Move Server.app to Trash.
  • Remove server data.
  • Re-Install Server.app from the Mac App Store.
  • Restore calendar and addressbook data.
  • Make sure that there's no "&" in the full name of the users (CoreDAVErrorDomain error 3).
  • Run a script to remove the "addressbook" groups.

How to

Backup calendar and addressbook data

sudo mv "/Library/Server/Calendar and Contacts/Data" /my/backup/location

Restore calendar and addressbook data

sudo mv "/Library/Server/Calendar and Contacts/Data" "/Library/Server/Calendar and Contacts/Data.blank"
sudo cp /my/backup/location "/Library/Server/Calendar and Contacts/Data"
sudo chown -R _calendar "/Library/Server/Calendar and Contacts/Data"

Remove server data

sudo rm -r /.ServerBackups
sudo rm -r /var/db/.ServerSetupDone
sudo rm -r /Library/Preferences/com.apple.serverd.plist
sudo rm -r /Library/Preferences/com.apple.servermgr_accounts.plist
sudo rm -r /Library/Preferences/com.apple.servermgr_certs.plist
sudo rm -r /Library/Preferences/com.apple.servermgr_info.plist
sudo rm -r /Library/Preferences/com.apple.servermgrd.plist
sudo rm -r /Library/PrivilegedHelperTools/com.apple.serverd
sudo rm -r /Library/Server

Credit: http://apple.stackexchange.com/a/179726/62173

Script to remove "addressbook" groups

To remove the hundreds of addressbook groups, which have all the same name "addressbook", open the Apple Script Editor and run the following script:

set counter to 0
display dialog "Name of group to delete?" default answer ""
set theGroupName to text returned of result
tell application "Contacts"
    repeat
        try
            set theGroup to group theGroupName
            delete theGroup
            set counter to counter + 1
        on error
            exit repeat
        end try
    end repeat
    save
    display dialog "Removed " & counter & " instances of the group" with icon caution buttons {"OK"} default button "OK"
end tell

When asked, enter the group name "addressbook".

Credit: http://apple.stackexchange.com/a/65846/62173

"Removed 2498 instances of the group" — yeehaaa!

Further resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment