Skip to main content
Jamf Nation, hosted by Jamf, is the largest Apple IT management community in the world. Dialog with your fellow IT professionals, gain insight about Apple device deployments, share best practices and bounce ideas off each other. Join the conversation.

Managing Database Backups Using the Jamf Pro Server Tools Command-Line Interface

Overview

This article describes how to create, restore, and schedule database backups using the Jamf Pro Server Tools command-line interface (CLI).

Note: The database backup functionality does not work with Jamf Pro Server Tools CLI 1.1.2 or earlier. If you want to back up your database using the CLI, you can download and use the latest version. For installation instructions, see the Using the Jamf Pro Server Tools Command-Line Interface Knowledge Base article.

Versions Affected

The CLI works with on-premise installations of Jamf Pro 10.0.0 or later.

Procedures

Note: You must configure the CLI before peforming these tasks. For instructions, see the Using the Jamf Pro Server Tools Command-Line Interface Knowledge Base article.

Backing Up the Jamf Pro Database

You can back up the database by executing the following command:

jamf-pro database backup

Restoring the Jamf Pro Database

You can restore the database by executing the following command:

jamf-pro database restore my-backup-file.sql

Note: Replace my-backup-file.sql with the path to your database backup file.

Scheduling Database Backups

  1. Verify that the database connection is working by executing the following command:
    jamf-pro database test-connection
  2. Execute the following command, replacing [name] with a custom schedule name and [time_format] with time and date criteria:
    jamf-pro database schedules create --schedule-name [name] --frequency "[time_format]"
    Note: Schedule names must be alphanumeric.

Time Formats

You can use global, Crontab (Linux and macOS only), or schtasks (Windows only) time formats as described below.

Global Frequency Syntax

You can use the following global frequency flags for all platforms:

hourly 
daily HH:MM 
weekly DAY HH:MM

For example, to schedule database backups to run weekly on Sundays at 12:00 p.m., you would enter the following:

jamf-pro database schedules create --schedule-name [name] --frequency "weekly SUN 12:00"

Crontab Syntax (Linux and macOS only)

Crontab requires five fields, each of which must be a number or an asterisk (*). The five fields are defined as follows:

minute (0 - 59)
| hour (0 - 23)
| | day of month (1 - 31)
| | | month (1 - 12)
| | | | day of week (0 - 6) (Sunday to Saturday)
| | | | |
| | | | |
| | | | |
* * * * *

Enter an asterisk (*) to include every possible value for a field.

Examples

The following command would back up the database at 00:01 (12:01 a.m.) every day:

jamf-pro database schedules create --schedule-name [name] --frequency "1 0 * * *"

The following command would back up the database at 23:45 (11:45 p.m.) every Saturday:

jamf-pro database schedules create --schedule-name [name] --frequency "45 23 * * 6"

Schtasks Syntax (Windows only)

Schtasks provides many options for scheduling database backups. For more information, see the following webpage:
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks

Example
jamf-pro database schedules create --schedule-name [name] --frequency "/sc weekly /d MON /st 06:05"

Stopping Scheduled Database Backups

Execute the following command:

jamf-pro database schedules remove --schedule-name [name]

Listing Scheduled Backups

To see a list of scheduled backups and their frequencies, execute the following command:

jamf-pro database schedules list

Getting Help

You can get additional usage information about the CLI by executing the following command:

jamf-pro help

Using the --help flag with any jamf-pro subcommand will display usage information about that command.

Additional Information

For additional information, see the Using the Jamf Pro Server Tools Command-Line Interface Knowledge Base article.

Like Comment
SOLVED Posted: by glutz

One thing that I struggled with is configuring password for jamf-pro and the result of this was the following error.

Error: Error 1045: Access denied for user 'jamfsoftware'@'localhost' (using password: YES)

How I was able to get around this was setting my password with single quotes and it seemed to work as expected after that.

Example:
jamf-pro config set --database-password 'yoursupersecretpassword'

Like