Monthly Archives

2 Articles

Posted by admin on

OS X Mount Active Directory Home Drive Automatically (Working Solution for OS X 10.10)

Prior to OS X 10.9 Mavericks here at the college we would use the option in the “Directory Utility” app to mount the Active Directory home drives. This was done by checking off “Use UNC path from Active Directory” but with OS X 10.9 Mavericks & OS X 10.10 Yosemite there was the adoptions of SMB2 which does not play well with Microsoft’s version of SMB. We would have drives mounting but not the drives we wanted. We would normally want their home folder mounted as (ex. /studentname) but instead it was now being mounted as (ex. share/studentname). This is how we’ve been running for the past two years and haven’t had much luck fixing it. 

Today with the help of a co-worker we were able to come up with an AppleScript that fixes this. Below is the simple script that I saved as an executable app and placed into the /Library/Scripts folder in our images. From here I added the app as a login item in the default profile. Once any user logs in the script would check to see what the users name is then look to Active Directory to poll what their Home Drive is. Next the script converts the backwards slashes “\” (used in the Windows World) to forward slashes “/” (Unix World) then mounts the drive. 

I’ve been testing this on a number of stations and now have it deployed out to some of our labs. 

If you want to use this script you need to make sure you go into “Directory Utility” and un-check “Use UNC path from Active Directory” since we no longer need this and now relying on this AppleScript to do the work.

In the script provided you will need to change “DOMAIN” to your campus domain. For an example our college it’s just “CAMPUS”.

Here’s the script below to use or feel free to download it:





set username to do shell script “whoami”

set homepath to do shell script “dscl ‘/Active Directory/DOMAIN/All Domains/’ -read /Users/” & username & ” | grep SMBHome: | cut -c 10- | sed ‘s/\\\\/\\//g’ “

tell application “Finder”


            mount volume “SMB:” & homepath

      end try

end tell



When I have the free time I want to convert this into a .plist script to use with launch daemon instead of relying on an app in the login items to make it a little cleaner. Until then this will do the trick and something that I’ve been looking into for some time now without success. 

Hope this helps out others that have been looking for a similar solution.


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:

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 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/ .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” “”>

<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 