Daily Archives

One Article

Posted by admin on

How To Backup Profile Manager Database (Working Solution for OS X 10.10)

For comments and questions please visit the edugeek forum here: http://www.edugeek.net/forums/mac/157905-backup-profile-manager-database-working-solution-os-x-10-10-a.html

It’s annoying that Apple has no easy solution for something that should be a major & required feature for it’s Profile Manager. With the help of the post here https://discussions.apple.com/thread/6855393 by @Strontium90 I had gone ahead and created scripts that I now have running on my server that will backup the Profile Manager Database daily. 

I’ve tested this and I was able to backup the database then erase/reset Profile Manager to scratch then run the restore and have the server backup and running with all the devices, groups etc.

Here are the commands:

Dump/Create backup of the database

sudo pg_dump -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 -c -f ~/Desktop/profileManager.sql

Erase/Reset Profile Manager database

sudo /Applications/Server.app/Contents/ServerRoot/usr/share/devicemgr/backend/wipeDB .sh

Restore Profile Manager

sudo -s
cat ~/Desktop/profileManager.sql | psql -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0

If you are doing daily backups like I am I had added this to the script. It will make a copy of the database and add the date & time and copy it to another folder.

cp ~/Desktop/profileManager.sql /Profile\ Manager\ Database\ Backups/$(date +%B_%d_%Y_Time_H%H_M%M)_profileManager.sql



For automatic backups I use the below scripts to automate a scheduled dump of the Profile Manager Database  to both a local folder on the server as well as a networked mounted drive so I would have the databases in two locations. 

This script is your “LaunchDaemons” script that sets the schedule. In one I’ve provided I have it set to 4:00am daily. You can change this to your preferred time.

Name of file “com.mactech.pmbackup.plist”


<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>

<plist version=”1.0″>
















    <false />




Once you’ve made needed changes to the above script place it at “/Library/LaunchDaemons /com.mactech.pmbackup.plist”

To load or make the script active you need to load it by running the following Terminal Command “launchctl load -w /Library/LaunchDaemons/com.mactech.pmbackup.plist”


Below is the script that the “com.mactech.pmbackup.plist” file run on the set schedule.

The First line dumps the database to the desktop so the latest dump is right there. 

The Second line copies the file and placed it into a folder at “/Profile Manager Database Backups”. You need to either create this folder or rename this line or remove the line if you do not wish to have it.

The Third line copies the file to a network share. I have the server setup to mount the share on login so it’s always there. Change “RemoteServerAddress_&_Share” to your network share.

** For the Second & Third lines the files are renamed by adding the Date & Time (ex. October_13_2015_Time_H04_M00_profileManager.sql).



sudo pg_dump -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 -c -f ~/Desktop/profileManager.sql

cp ~/Desktop/profileManager.sql /Profile\ Manager\ Database\ Backups/$(date +%B_%d_%Y_Time_H%H_M%M)_profileManager.sql

cp ~/Desktop/profileManager.sql /RemoteServerAddress_&_Share/$(date +%B_%d_%Y_Time_H%H_M%M)_profileManager.sql


Enjoy 