Apple macOS Server – Reset

If you’ve ran into a road block and need to reset the database and everything makes the profile manager work the scripts below will help.

I have had to do this personally after removing a device from profile manager and tried to add it again.

NOTE: You will need to reinput all the server information.

sudo /Applications/Server.app/Contents/ServerRoot/usr/share/devicemgr/backend/wipeDB.sh
sudo /Applications/Server.app/Contents/ServerRoot/usr/share/devicemgr/backend/wipeDB.sh
sudo serveradmin stop devicemgr
sudo serverctl disable service=com.apple.DeviceManagement.devicemgrd
sudo serverctl disable service=com.apple.DeviceManagement.postgres
sudo killall -9 -u _devicemgr dmrunnerd devicemgrd migration_tool sd_relocator dmpgHelper
sudo mv /Library/Server/ProfileManager/Config/ServiceData/Data/PostgreSQL ~/.Trash/PostgreSQL_$RANDOM
sudo mv /Library/Server/ProfileManager/Config/ServiceData/Data/backup ~/.Trash/backup_$RANDOM
sudo /Applications/Server.app/Contents/ServerRoot/usr/libexec/deviceManagerCommon.sh

In some case you may need to remove macOS Server and start completely over

sudo rm -rf /Applications/Server.app
sudo rm -rf /Library/Server

Reference: https://support.apple.com/en-us/HT202523

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.