Skip navigation

How to backup profile manager?

4167 Views 9 Replies Latest reply: Nov 18, 2013 10:43 AM by Marc Kerr RSS
Zorko993443 Calculating status...
Currently Being Moderated
Mar 9, 2012 5:47 AM

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

iPhone 4, iOS 4.3.3
  • HansGoudswaard Calculating status...
    Currently Being Moderated
    Mar 9, 2012 6:38 AM (in response to Zorko993443)
  • Christoph Murauer Calculating status...
    Currently Being Moderated
    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.

  • sparky316 Level 1 Level 1 (0 points)
    Currently Being Moderated
    May 2, 2013 10:08 AM (in response to Christoph Murauer)

    This solution works in Mac OS X 10.7 but not in OS X 10.8. Apple has changed the database some how.

  • Marc Kerr Level 1 Level 1 (0 points)
    Currently Being Moderated
    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

  • RafaMertens Calculating status...
    Currently Being Moderated
    Oct 28, 2013 11:10 AM (in response to Marc Kerr)

    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?

  • RafaMertens Level 1 Level 1 (0 points)
    Currently Being Moderated
    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.

  • Marc Kerr Level 1 Level 1 (0 points)
    Currently Being Moderated
    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.

  • Marc Kerr Level 1 Level 1 (0 points)
    Currently Being Moderated
    Nov 18, 2013 10:43 AM (in response to Marc Kerr)

    Correction, sorry. Use the following to do the restore.

     

    sudo psql -U _devicemgr -d device_management -h /Library/Server/ProfileManager/Config/var/PostgreSQL/ -f $HOME/device_management.sql

Actions

More Like This

  • Retrieving data ...

Bookmarked By (2)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.