As part of working with Jamf Pro, I prefer to be able to save as much of the existing configuration of it as possible. Normally I can do this via the Jamf Pro Classic API and I have a number of blog posts showing how I use the API to create backups of my Jamf Pro configuration.
However, one set of data which is not accessible via the API are the Self Service bookmarks.
If I want to back up this information, is there a way outside of the API? It turns out that there is. For more details, please see below the jump.
After some digging around, I discovered that the Self Service bookmarks are automatically downloaded from the Jamf Pro server and stored locally on each Mac in the following directory:
/Library/Application Support/JAMF/Self Service/Managed Plug-ins
In this directory, there are .plist files named with the Jamf Pro ID number of the relevant Self Service bookmark.
To make backups of the Self Service bookmarks, I’ve written a script which performs the following tasks:
- If necessary, create a directory for storing backup copies of the Self Service bookmark files.
- Make copies of the Self Service bookmark files.
- Name the copied files using the title of the Self Service bookmark.
- Store the copied bookmarks in the specified directory.
Once the script is run, you should see copies of the Self Service bookmark files appearing in the script-specified location.
This location can be set manually or created automatically by the script.
The script is available below, and at the following address on GitHub:
Jamf_Pro_Self_Service_Bookmark_Backup.sh:
#!/bin/bash | |
# This script is designed to do the following: | |
# | |
# 1. If necessary, create a directory for storing backup copies of Jamf Pro Self Service bookmark files. | |
# 2. Make copies of the Self Service bookmark files. | |
# 3. Name the copied files using the title of the Self Service bookmark. | |
# 4. Store the copied bookmarks in the specified directory. | |
# | |
# If you choose to specify a directory to save the Self Service bookmarks into, | |
# please enter the complete directory path into the SelfServiceBookmarkBackupDirectory | |
# variable below. | |
SelfServiceBookmarkBackupDirectory="" | |
# If the SelfServiceBookmarkBackupDirectory isn't specified above, a directory will be | |
# created and the complete directory path displayed by the script. | |
error=0 | |
if [[ -z "$SelfServiceBookmarkBackupDirectory" ]]; then | |
SelfServiceBookmarkBackupDirectory=$(mktemp -d) | |
echo "A location to store copied bookmarks has not been specified." | |
echo "Copied bookmarks will be stored in $SelfServiceBookmarkBackupDirectory." | |
fi | |
self_service_bookmarks="/Library/Application Support/JAMF/Self Service/Managed Plug-ins" | |
for bookmark in "$self_service_bookmarks"/*.plist | |
do | |
echo "Processing "$bookmark" file…" | |
bookmark_name=$(/usr/bin/defaults read "$bookmark" title) | |
cat "$bookmark" > "$SelfServiceBookmarkBackupDirectory/${bookmark_name}.plist" | |
if [[ $? -eq 0 ]]; then | |
echo "$bookmark_name.plist processed and stored in $SelfServiceBookmarkBackupDirectory." | |
else | |
echo "ERROR! Problem occurred when processing $self_service_bookmarks/$bookmark file!" | |
error=1 | |
fi | |
done | |
exit $error |