Backblaze provides a fantastic set of command-line utilities which make it ideal for deploying and managing through Addigy. The first step of successfully using Backblaze and Addigy together is getting a solid installation.   


The best way to install Backblaze is by creating a Custom Software item with your organization's Backblaze settings included. You can learn more about creating a basic Custom Software item in our article Creating Custom Software.    


We'll go over the necessary scripts in a moment. But for now, it should look something like this:



Just a title, icon, and the installer .dmg file are added so far.


Now, there are three scripts which we can add to this installation: condition, install, and removal. The condition and install scripts are mandatory for this item to function properly on a policy level.


The Installation script will look like this:


# The Backblaze email associated with your account
login="myusername@mycompany.com"

# The password associated with your account
password='yourPasswordHere'

/usr/bin/hdiutil attach -nobrowse "/Library/Addigy/ansible/packages/Backblaze (5.0.0)/install_backblaze.dmg"

"/Volumes/Backblaze Installer/Backblaze Installer.app/Contents/MacOS/bzinstall_mate" -nogui bzdiy -signin "${login}" "${password}"

/usr/sbin/diskutil unmount "/Volumes/Backblaze Installer"


Note: This method stores your Backblaze password in plain text within Addigy. Any users with access to your Custom Software items will be able to see this text.


If you are concerned with the security of your Backblaze account with this method, you can remove the $login and $password portions of the installation and sign in to Backblaze manually, or let your end-user sign in for themselves.


The Condition script looks like this:


if [ -e "/Library/Backblaze.bzpkg/bztransmit" ]; then
    echo "Backblaze already installed. Not installing"
    exit 1
else
    echo "Backblaze not installed. Attempting to install now..."
    exit 0
fi


This is the simplest condition that functions properly. A more complex condition could be designed to check the specific version of Backblaze and upgrade the software if an older version is detected.


Also, make sure the Condition field has the Install on Success toggled ON:



Finally, if you'd like to remove Backblaze when it is removed from a policy, then add this Removal script to your Custom Software:


# Copyright (c) 2007-2010 Backblaze Inc. All rights reserved.
#
# Shout out to Adam Fisk for writing about AppleScript uninstallers!

function die {
    echo $*
    exit 1
}

function remove {
    rm -r "$1" || die "Could not remove file: $1"
}

function shutdown_bzserv {
    local output=`ps -cA | grep bzserv`
    local bz_plist='/Library/LaunchDaemons/com.backblaze.bzserv.plist'
    if [ -n "$output" ]
    then
        test -f $bz_plist && launchctl unload $bz_plist
        test -f $bz_plist && remove $bz_plist
    else
        if [ -f $bz_plist ]
        then
            remove $bz_plist
        fi
    fi
}

function clean_library_backblaze {
    local bz_pkgs='/Library/Backblaze.bzpkg'
    local bz_apps='/Library/Backblaze'
    if [ -d $bz_apps ]
    then
        remove $bz_apps
    fi
    if [ -d $bz_pkgs ]
    then
        remove $bz_pkgs
    fi
}

function clean_system_preferences_backblaze {
    local bz_pref_pane='/Library/PreferencePanes/BackblazeBackup.prefPane'
    if [ -d $bz_pref_pane ]
    then
        remove $bz_pref_pane
    fi
}

function clean_applications_backblaze {
    local bz_app='/Applications/Backblaze.app'
    if [ -d $bz_app ]
    then
        remove $bz_app
    fi
}

function clean_misc {
    local bz_extbx="/Library/Application Support/ExtBX"
    if [ -d "$bz_extbx" ]
    then
        remove "$bz_extbx"
    fi
}

function shutdown_bzbmenu {
    local output=`ps -cA | grep bzbmenu`
    if [ -n "$output" ]
    then
        killall -9 bzbmenu
    fi
}

function restore_ac_powersetting_to_normal {
    bz_victoryfile="/Library/Backblaze/bzdata/bzreports/bzstat_endfirstbackupmillis.txt"
    if [ ! -f $bz_victoryfile ]
    then
        pmset -c sleep 11 &> /dev/null
    fi
}

function unload_bzbmenu {
    for dir in /Users/*
    do
        userName=${dir:7}
        if [ $userName == 'Guest' -o $userName == 'Shared' ]
        then
            continue
        fi
        bzbmenuPlist="$dir/Library/LaunchAgents/com.backblaze.bzbmenu.plist"
        if [ -f "$bzbmenuPlist" ]
        then
            sudo -u "$userName" launchctl unload "$bzbmenuPlist"
            remove "$bzbmenuPlist"
        fi
    done
}

function bz_main {
    shutdown_bzbmenu
    shutdown_bzserv
    clean_library_backblaze
    clean_system_preferences_backblaze
    clean_applications_backblaze
    clean_misc
    unload_bzbmenu
}

# main
bz_main


Confirm and Deploy the changes you've made to this Custom Software. It is highly recommended that you use a test policy and machine to ensure that Custom items in the Catalog are robust and effective before pushing them to your production devices.


Huge thanks to Benjamin Morales, @bmorales on MacAdmins, for his scripts which were adapted for use in this article.