Zorko993443

Q: 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

Close

Q: How to backup profile manager?

  • All replies
  • Helpful answers

  • by HansGoudswaard,

    HansGoudswaard HansGoudswaard Mar 9, 2012 6:38 AM in response to Zorko993443
    Level 1 (0 points)
    Mar 9, 2012 6:38 AM in response to Zorko993443
  • by Christoph Murauer,

    Christoph Murauer Christoph Murauer Mar 12, 2012 6:37 PM in response to Zorko993443
    Level 1 (25 points)
    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.

  • by carter.x,

    carter.x carter.x Nov 20, 2012 6:42 AM in response to Christoph Murauer
    Level 2 (249 points)
    Nov 20, 2012 6:42 AM in response to Christoph Murauer
  • by sparky316,

    sparky316 sparky316 May 2, 2013 10:08 AM in response to Christoph Murauer
    Level 1 (0 points)
    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.

  • by Marc Kerr,

    Marc Kerr Marc Kerr Aug 28, 2013 1:26 PM in response to sparky316
    Level 1 (0 points)
    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

  • by RafaMertens,

    RafaMertens RafaMertens Oct 28, 2013 11:10 AM in response to Marc Kerr
    Level 1 (1 points)
    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?

  • by RafaMertens,

    RafaMertens RafaMertens Oct 29, 2013 3:26 AM in response to Zorko993443
    Level 1 (1 points)
    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.

  • by Marc Kerr,

    Marc Kerr Marc Kerr Nov 18, 2013 10:07 AM in response to Zorko993443
    Level 1 (0 points)
    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.

  • by Marc Kerr,

    Marc Kerr Marc Kerr Nov 18, 2013 10:43 AM in response to Marc Kerr
    Level 1 (0 points)
    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

  • by JAGUK,

    JAGUK JAGUK Mar 30, 2016 6:56 AM in response to Marc Kerr
    Level 1 (33 points)
    Servers Enterprise
    Mar 30, 2016 6:56 AM in response to Marc Kerr

    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

  • by JAGUK,

    JAGUK JAGUK Mar 30, 2016 8:16 AM in response to Marc Kerr
    Level 1 (33 points)
    Servers Enterprise
    Mar 30, 2016 8:16 AM in response to Marc Kerr

    Hi again,

     

    Just tried to dump out the device_mangement DB and apparent;y it doesn't exist in that location oddly.

     

    Only files in that location are a couple of aliases and this ".s.PGSQL.5432.lock"

     

    Anyone have any ideas?

     

    I'm running 10.9.5 and Server 3.2.2

  • by JAGUK,

    JAGUK JAGUK Mar 30, 2016 8:27 AM in response to Marc Kerr
    Level 1 (33 points)
    Servers Enterprise
    Mar 30, 2016 8:27 AM in response to Marc Kerr

    Not to worry... found it in another post!

     

    For anyone else following this breadcrumb trail, I found a working backup command for Mavericks & Yosemite here How do I backup profile manager database on OS X Yosemite?