We are 1 week into 2019, and I was thinking about a new topic to kick this new year into action. I still have some pending tutorials in mind, but before diving into another long topic, what’s better to start a new year than to start with some good practices? You know, like those resolutions we tend to make following the festivities each year… One of those could be making backups all those things you highly value. Your Jamf Pro server for instance!
If you’re using Jamf Cloud, you have nothing to worry about. Jamf has some powerful wizards on their payroll who are taking care of all this for you.
If you are hosting your own server however, you have the important responsibility to do this yourself. And if you fancy to keep your job in 2019, you might want to think about backing up this oh so important little server.
So, what’s the story with your Jamf Pro server? Are you confident all is sorted out? Are you sure everything is running smoothly? Maybe it’s a good moment to have a look and check again.
Let’s have a look at some options here.
For sure, you could backup the entire machine, which is, especially for VM’s quite a straight forward thing to do. A backup of the entire server includes the full setup and installation of Java, mySQL… Any customisation you made on a Tomcat level (when running Jamf Pro on a custom port for instance). As well as the Jamf Pro Database of course.
I would however still make sure I have separate backups of Jamf Pro database as well. Those are going to be smaller than a full server backup, and they also give you more flexibility when things go wrong.
My strategy would be something like a full server backup before every upgrade of Jamf Pro (or any server level change), combined with at least a weekly database backup. When things go horribly wrong, you’ll be able to restore the server backup, and replace the database with most recent backup.
The full server backups will of course depend from your (virtual) infrastructure, so let’s limit this quick discussion to database backups only.
As we all know, the entire Jamf Pro server lives inside the mySQL database. Except server level settings such as the server.xml, database.xml or any other Tomcat tweaks of course. This means that all your Jamf Pro settings, profiles, policies, device inventory, etc are stored within that mySQL database. So the only thing you really need, to avoid the ultimate disaster, is a backup of that precious mySQL database.
For sure you could use the native ‘mysqldump‘ command to make the backups, and schedule them via a cron job. But why would you make your live more complicated than necessary if someone already did the heavy lifting for you? Yes, Jamf already provides you with a tool to do all of this without too much effort!
No, I’m not talking about the Jamf Database Utility… For different reasons, and this is my personal opinion, I’ve never been a big fan of this tool. But since Jamf Pro 10.7 there is a nice new tool available!
I’m talking about the Jamf Pro server tools. This has been around since Jamf Pro 10.7 and is automatically installed in the bundled Jamf Pro installer ever since. It’s compatible with all Jamf Pro version 10.0.0 or later and replaces the Jamf Pro Database Utility.
So how does it work?
The first thing to do before you can use the tool is: right – check if it’s installed. To do this, just run the following command (Linux or macOS):
$ which jamf-pro
This should give you the path of the Jamf Pro Server Tools:
Or for Windows, just have a look at C:\Program Files\JSS\bin\jamf-pro.exe
Note: Just check if the exe file is there. Don't try to run it, as also on Windows this is a Command Line Tool. See below.
(You can also use the Server Tools GUI, but I'll leave that for another time)
If for one reason or another you don’t have the tool installed, have a look at the installation options here. I would go for the option to install it via a package manager, but if you do download it manually, make sure to put it in the correct location. See above.
Next, you’ll have to configure it as it needs the credentials to access the mySQL database. Go to your Terminal, Command Line or Windows Powershell and run:
$ jamf-pro config set --database-host localhost --database-port 3306 --database-name jamf --database-user jamfDbUser --database-password jamfDbUserPassword --backup-dir /path-to-backup-dir
Change the database name, database user and password with those of your Jamf Pro mySQL connection.
If you are not running mySQL on the same server, or you granted access based on IP address instead of localhost, specify the host
and finally, specify the path where you want the backups to be stored.
I quickly set the target directory to /tmp. Just for testing, but obviously this might not be the smartest location for you backups :-)
In case you don’t remember the username and password you configured when you granted access to your mySQL Database (yes, it happens…), have a look at the DataBase.xml file of your Jamf Pro Server:
Windows: C:\Program Files\JSS\Tomcat\webapps\ROOT\WEB-INF\XML\DataBase.xml
That’s it for the configuration! Next you will want to test the connection:
$ jamf-pro database test-connection SUCCESS connected to the database
And run a backup:
$ jamf-pro database backup Database backup file: /tmp/2019-01-08-014941.sql.gz Database size: 0.00 MB Note: This is the raw database size. The exported data may be significantly smaller. Backing up the database... mysqldump: [Warning] Using a password on the command line interface can be insecure. [0.02 MB] - Compressing Backup complete
Easy right? Compared to the old Database Utility, I love this little tool. So once you got this to work, you’ll want to schedule your weekly backups. or any schedule you actually feel necessary. For instance:
$ jamf-pro database schedules create --schedule-name sunday --frequency "weekly SUN 12:00"
The above syntax works on all platforms and uses the following flags in between the quotes:
weekly DAY HH:MM
For Linux and Mac you can however use the specific crontab syntax if you prefer:
Or for Windows you can use ‘Schtasks‘:
$ jamf-pro database schedules create --schedule-name MON --frequency "/sc weekly /d MON /st 06:05"
To list all your scheduled backups:
$ jamf-pro database schedules list
And to remove a schedule:
$ jamf-pro database schedules remove --schedule-name [name] for instance: $ jamf-pro database schedules remove --schedule-name SUN
Finally, not immediately linked to creating backups, the Jamf Pro server tools actually also allow you to restart the Jamf Pro server and/or mySQL. (Similar to the old Database Utility)
To restart Jamf Pro:
$ jamf-pro server start $ jamf-pro server stop $ jamf-pro server restart
And to restart mySQL:
$ jamf-pro database start $ jamf-pro database stop $ jamf-pro database restart
That’s it! Handy no? If you are still using the Database Utility, I’d recommend to move to the CLI tool, and if you are not using anything yet… well yeah… you should. Now!