Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to backup profile manager?

Is there a way to backup the database in the profile manger?

iPhone 4, iOS 4.3.3

Posted on Mar 9, 2012 5:47 AM

Reply
12 replies

Mar 12, 2012 6:37 PM in response to Zorko993443

Hello !


To backup the DB in Terminal :


sudo pg_dump -U _postgres -c device_management > $HOME/device_management.sql


To restore the DB in Terminal :


sudo serveradmin stop devicemgr

sudo serveradmin start postgres

sudo psql -U _postgres -d device_management -f $HOME/device_management.sql

sudo serveradmin start devicemgr


The wholte tutorial can be found here :


Mac OS X 10.7 Lion Server # 10 : Daten des Wiki Servers übersiedeln.

Mac OS X 10.7 Lion Server # 9 : PostgreSQL.

Sorry, I wrote it in german but translate.google.com is your friend - or send a message if you have some questions.


C. M.

Aug 28, 2013 1:26 PM in response to sparky316

Yes Apple moved everything inside the Server.app into the ServerRoot folder. I beleive you shoudl be runnin the commands from there. There are actually a couple of instances of Postgresql running you your Mac. The socket for the the services run by server are now in the following directory.


/Library/Server/PostgreSQL\ For\ Server\ Services/Socket/


You can run the following command to get the dump to work. All on one line.


sudo /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_dump -U _postgres -h /Library/Server/PostgreSQL\ For\ Server\ Services/Socket/ -c device_management > $HOME/device_management.sql


Better yet use this guys scripts.

http://www.practiceofcode.com/post/44574319896/updated-postgresql-backup-scripts -for-10-8-2-os-x

Oct 28, 2013 11:10 AM in response to marc7654

Hi Marc Kerr.


It worked perfectly to create the Backup on the OS X Server 10.8.


But I couldn't restore..

Does anyone knows the commands to restore the Profile Manager on the OS X Server 10.8?

Oct 29, 2013 3:26 AM in response to Zorko993443

For all those that had the same problem as me trying to restore the Profile Manager on Mountain Lion here are the commands I figured out how to use.


-- Backup Profile Manager --


sudo ./pg_dump -h "/Library/Server/PostgreSQL For Server Services/Socket" --format=c --compress=9 --blobs --username=_devicemgr --file=/tmp/device_management.pgdump device_management



-- Restore Profile Manager --


sudo serveradmin stop devicemgr

sudo serveradmin start postgres_server


sudo ./dropdb -h "/Library/Server/PostgreSQL For Server Services/Socket" -U _devicemgr device_management

sudo ./createdb -h "/Library/Server/PostgreSQL For Server Services/Socket" -U _devicemgr device_management


sudo -u _postgres ./pg_restore -h "/Library/Server/PostgreSQL For Server Services/Socket" -d device_management -U _devicemgr -n public --single-transaction /tmp/device_management.pgdump


sudo serveradmin start devicemgr



Regards.

Nov 18, 2013 10:07 AM in response to Zorko993443

Thought I should update this info for Mavericks (10.9) and Server 3 because Apple changed things again, just slightly.


Apple removed /user/bin/psql and associated apps so now you only have one psql to deal with and it’s in your environment path. Running ‘which psql’ will show you /Applications/Server.app/Contents/ServerRoot/usr/bin/psql


That has simplified things a little.


The socket has moved also and is now in:

/Library/Server/ProfileManager/Config/var/PostgreSQL/


So to get into the database run this command.

sudo psql -U _devicemgr -d device_management -h /Library/Server/ProfileManager/Config/var/PostgreSQL/


Use \d to see the tables \h to get help \q to exit. See the man page or the postgresql documentation online for more if you are new to this, like me.


The basic backup/dump command is:

pg_dump -U _devicemgr -h /Library/Server/ProfileManager/Config/var/PostgreSQL/ -c device_management > $HOME/device_management.sql


If you use the above psql command to create the backup it will be in a text format. Apparently that means you need to also use psql to restore. I’m sure there are better ways to do the backup and restore. Having a full TimeMachine backup of your server works well.


For the restore I modified the previously posted commands just a bit.

---

sudo serveradmin stop devicemgr


sudo serveradmin start postgres


sudo dropdb -h /Library/Server/ProfileManager/Config/var/PostgreSQL/ -U _devicemgr device_management


sudo createdb -h /Library/Server/ProfileManager/Config/var/PostgreSQL/ -U _devicemgr device_management


sudo psql -U _devicemgr -d device_management -h /Library/Server/ProfileManager/Config/var/PostgreSQL/


sudo serveradmin start devicemgr

---

I rand all this on a test server and it appears to work.

Mar 30, 2016 6:56 AM in response to marc7654

Thanks Marc for your updated post re backing up Mavericks Server.


I realise that this is an old post but unfortunately I am currently in a position where I am having to rebuild our server (long and unnecessary story!) and the one thing I want to avoid is having to re-enroll all of the devices again so this should help enormously!


One question though however, does anyone know if this backup would include the deployable Settings for device groups? I'm hoping this would be but just wanted to double check!


Many thanks in advance, Justin

How to backup profile manager?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.