Home > Jamf Pro, Mac administration, Scripting > Backing up Jamf Pro Self Service bookmarks

Backing up Jamf Pro Self Service bookmarks

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.

Screen Shot 2020 09 27 at 11 29 48 AM

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.

Screen Shot 2020 09 27 at 11 31 16 AM

To make backups of the Self Service bookmarks, I’ve written a script which performs the following tasks:

  1. If necessary, create a directory for storing backup copies of the 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.

Once the script is run, you should see copies of the Self Service bookmark files appearing in the script-specified location.

Screen Shot 2020 09 27 at 11 43 33 AM

This location can be set manually or created automatically by the script.

Screen Shot 2020 09 27 at 11 42 59 AM

The script is available below, and at the following address on GitHub:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/Jamf_Pro_Self_Service_Bookmark_Backup

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
view raw gistfile1.txt hosted with ❤ by GitHub

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment