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

Question:

Question: How do I backup profile manager database on OS X Yosemite?

Hello guys,

I'm struggling to find an answer on how to backup profile manager database(devices, groups etc.) on Yosemite(server 4), so far I only found a few threads for Mavericks (10.9) & Server 3 saying to type the following command via terminal: "sudo pg_dump -U _postgres -c device_management > $HOME/device_management.sql"

Although this command applies to Mavericks(server 3) I decided to give it a shot but as expected I got this error message:

"pg_dump: [archiver (db)] connection to database "device_management" failed: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?"

I also tried to backup & restore profile manager's database with TimeMachine but unfortunately it didn't worked..

It seems that TimeMachine misses the profile manager's data folders(see thread: Profile Manager not being backed up in Time Machine?)

and I saw that other people also complained about this problem.


As we're a company who holds thousands of devices & integrates them on daily basis to profile manager, I would be very pleased to know how to backup our Profile manager's database.
Please see this question as HIGH importance, I really hope to get an answer ASAP..

Thanks in advance for all the repliers! 🙂


Yours sincerely,

Daniel Adler.

iPad Mini, iOS 8.1.3, OS X Server ver. 4

Posted on

Reply
Question marked as Solved
Answer:
Answer:

Darn my feeble typing fingers. In the original post I put a space in the command path... Sigh. So sorry. You need:


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

Notice in that /Library/Server/ProfileManager/Config/var/PostgreSQL is correct, not /Library/Server/ ProfileManager/Config/var/PostgreSQL (grr).

Automating the process is turning the command into a script and then using cron or launchd to run it automatically.

Reid

Apple Consultants Network

Author "Yosemite Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Control and Collaboration" :: Exclusively available in Apple's iBooks Store

Posted on

Question marked as Helpful

Mar 9, 2015 4:12 PM in response to Đaniel In response to Đaniel

Antonio is correct. (Hey buddy. Hope all is well). pg_restore can be used to restore. However, I tend to be lazy as pg_restore is a bear of a command to get the syntax correct. I've used the following with success (you must promote yourself to root (sudo -s)):


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

There’s more to the conversation

Read all replies

Page content loaded

Mar 2, 2015 4:06 PM in response to Đaniel In response to Đaniel

In theory, Time Machine is supposed to do this.

I, much like you, don't trust it and prefer to do it myself. Try this:


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


Adjust your output path if needed. Automate to perform daily.


Reid

Apple Consultants Network

Author "Yosemite Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Control and Collaboration" :: Exclusively available in Apple's iBooks Store

Mar 2, 2015 4:06 PM

Reply Helpful

Mar 4, 2015 5:42 AM in response to Strontium90 In response to Strontium90

Hi Strontium90,

Thanks for your reply!! 🙂

I tried your command, but unfortunately i got the following error msg:

"too many command-line arguments (first is "devicemgr_v2m0")

Try "pg_dump --help" for more information."


Please correct me if I'm wrong: assuming command was successful, I should've seen 'profileManager.sql' file at my desktop(output path = ~/Desktop/) which is the Profile Manager's database file I guess, right? and where is the restoration path located? in case I want to restore Profile Manager's database with the created backup file('profileManager.sql').

Also you mentioned: "Automate to perform daily", how can I automate this command?
Thanks a lot for your support!

Have a nice day.

Yours sincerely,

Daniel Adler.

Mar 4, 2015 5:42 AM

Reply Helpful
Question marked as Solved

Mar 5, 2015 9:26 AM in response to Đaniel In response to Đaniel

Darn my feeble typing fingers. In the original post I put a space in the command path... Sigh. So sorry. You need:


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

Notice in that /Library/Server/ProfileManager/Config/var/PostgreSQL is correct, not /Library/Server/ ProfileManager/Config/var/PostgreSQL (grr).

Automating the process is turning the command into a script and then using cron or launchd to run it automatically.

Reid

Apple Consultants Network

Author "Yosemite Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Author "Mavericks Server – Control and Collaboration" :: Exclusively available in Apple's iBooks Store

Mar 5, 2015 9:26 AM

Reply Helpful (4)

Mar 9, 2015 8:17 AM in response to Strontium90 In response to Strontium90

Great!! it worked!! 🙂
Thank you very much, Strontium90!

But I still don't have any idea on how to restore the backup file(profileManager.sql), so I can retrieve my Profile manager's database back. I tried to import the 'profilemanager.sql' file to '/Library/Server/ ProfileManager/Config/var/PostgreSQL'(after I made changes via profile manager and typed the backup command), but unfortunately it didn't restored my changes. Is there a special command for that? or a specific path which I need to import 'profileManager.sql' to?


Thanks again for your help! 🙂

Daniel.

Mar 9, 2015 8:17 AM

Reply Helpful
Question marked as Helpful

Mar 9, 2015 4:12 PM in response to Đaniel In response to Đaniel

Antonio is correct. (Hey buddy. Hope all is well). pg_restore can be used to restore. However, I tend to be lazy as pg_restore is a bear of a command to get the syntax correct. I've used the following with success (you must promote yourself to root (sudo -s)):


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

Mar 9, 2015 4:12 PM

Reply Helpful (2)

Apr 3, 2015 1:59 PM in response to Strontium90 In response to Strontium90

Strontium,


Thanks for your help on this, it has come in handy! After importing our profileManager.sql file and logging into Profile Manager, we are receiving this error when selecting the devices or device groups: A Server Error has Occurred, please reload. Have you seen this happen before after restoring from backup? We are able to browse Users and Groups just fine.


Thanks again,


Barron

Apr 3, 2015 1:59 PM

Reply Helpful

May 25, 2015 7:25 AM in response to Strontium90 In response to Strontium90

Strontium90 & Antonio Rocco
THANKS YOU VERY MUCH GUYS!! your commands worked like a charm!

Sorry for my long disappearance, I was between projects so I didn't had the time to fully test the backup and restore commands.

So, if anyone is interesting to know how I tested the backup & restore commands please do the followings:


1.Create groups and devices & enter some devices to groups via Profile Manager.

2.Backup Profile Manager database(via terminal: sudo pg_dump -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 -c -f ~/Desktop/profileManager.sql)

3.Erase profile manager database(by typing the following command via terminal:

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

4.Restore - type via terminal:
1. sudo -s

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


5.Go back to Profile Manager and you should see all your erased database back! you can also fully control the restored devices!



*A tip for automatic Profile Manager backup: Run it late at night to avoid any actions on Profile Manager during backup. (I'm using macscheduler, you can download it from: macscheduler.net).

Have a great day!

Yours sincerely,

Daniel.

May 25, 2015 7:25 AM

Reply Helpful (2)

May 25, 2015 7:33 AM in response to bfuentes In response to bfuentes

Hello Bfuentes,

From my experience the: "A Server Error has Occurred, please reload" is a result of corrupted database on Profile Manager, when you doing the backup do you make sure nothing is running via Profile Manager? I guess you tried the backup & restore functions like me, so I suggest that you follow my steps above on how to backup & restore Profile Manager's DB.

Also I suggest you to quit profile manager(browser) before backup, maybe something is running in the process which interferes the backup.

Have a nice day,

Daniel.

May 25, 2015 7:33 AM

Reply Helpful

Aug 18, 2015 7:07 AM in response to Strontium90 In response to Strontium90

Thank you @Strontium90 I used your method and I was able to create a script and launch daemon that creates a backup daily to have backed up to an external share.


I tested your method and I was able to back and restore with successful results.


I've blogged about this here:

http://twistedmac.com/index.php/22-mac-os/36-backup-profile-manager-database

Aug 18, 2015 7:07 AM

Reply Helpful

Nov 15, 2015 2:35 PM in response to Đaniel In response to Đaniel

Hello Daniel,


So your steps will allow me to even to restore a previous time machine backup of the file?


How could this be achieved? Anyone?


I am getting the "A Server Error has Occurred, please reload" errors on my current database after updating, but even reverting the whole machine back didn't allow profile Manager to work.


So I want to just grab the file from time machine, what do I need to add to your backup command to do this?

Nov 15, 2015 2:35 PM

Reply Helpful

Nov 15, 2015 4:02 PM in response to Đaniel In response to Đaniel

sudo pg_dump -h/Volumes/USB_DRIVE/Backups.backupdb/mps-macserver/2015-08-26-000125/”Server HD”/Library/Server/ProfileManager/Config/var/PostgreSQL –U _devicemgr devicemgr_v2m0 -c -f ~/Desktop/profileManager.sql


Basically something as above ^^ to get the database from a previous backup (without doing a complete restore from time machine)


Doesn't seem to work for me, getting the below errors:


pg_dump: too many command-line arguments (first is "–U")

Try "pg_dump --help" for more information.

Nov 15, 2015 4:02 PM

Reply Helpful

Nov 17, 2015 4:41 AM in response to Đaniel In response to Đaniel

I backup our various OS X servers using 'Bender'. See http://robotcloud.screenstepslive.com/s/2459/m/5322/l/94467-bender-automated-bac kup-of-os-x-server-settings


It now backups the PostgreSQL databases as well i.e. the one used by Profile Manager. You would then use some other backup mechanism e.g. Time Machine to back those up along with the rest of the server.

Nov 17, 2015 4:41 AM

Reply Helpful

Jan 26, 2016 12:30 PM in response to Strontium90 In response to Strontium90

I tested this out a few months ago and had positive results so I've been backing up our profile managers weekly. Finally had cause to restore one and none of my devices are showing up.


Has something changed? This one only had a few devices enrolled, but if this doesn't work I need to change how I back the rest of these up.


First time I tried it it restored the device group we set up but not any of the devices. Subsequent attempts don't even import the device group.


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

Jan 26, 2016 12:30 PM

Reply Helpful

Mar 31, 2016 10:05 AM in response to Đaniel In response to Đaniel

Hey guys,


I'm just setting up a new 10.11 server and attempted to import that PM data from a live 10.9 server via this method and although it completed the import, there we a lot of errors and subsequently PM was pretty broken ( i.e. wouldn't load in the browser).


I should maybe have asked here first but thought I'd give it a go as I was in a test environment!


Anyone know if there is a method to achieve what I'm attempting? Or have Apple moved the goalposts as per usual?


Cheers!

Mar 31, 2016 10:05 AM

Reply Helpful
User profile for user: Đaniel

Question: How do I backup profile manager database on OS X Yosemite?