Backing Up and Restoring the Database Using the Jamf Pro Server Tools Command-Line Interface

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

Warning:
You must use Jamf Pro Server Tools 2.7.7 or later to perform database backups with Jamf Pro 10.27.0 or later. Using an earlier version of Jamf Pro Server Tools to back up your database will result in an unrestorable backup. After installing or upgrading to Jamf Pro 10.27.0 or later, confirm which version of Jamf Pro Server Tools you have installed by doing one of the following:
  • CLI: Execute the following command: jamf-pro --version
  • GUI: Verify the installed versions of the GUI and CLI displayed on the Preferences pane.
If you do not have Jamf Pro Server Tools 2.7.7 or later installed, see the installation instructions in the following articles:
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 article.

Backing Up the Jamf Pro Database

You can back up the database by executing the following command:
jamf-pro database backup
You can configure the number of backups you want to keep by executing the following command:
jamf-pro config set --backup-limit number_of_backups
For example, if you want to retain only the 10 most recent backups, you would enter the following:
jamf-pro config set --backup-limit 10
Note:

The backup file limit is based on the backup file dates and not the backup filenames. The backup file limit includes manual backups and any other .sql.gz files in the backups folder.

Restoring the Jamf Pro Database

You can restore the database by executing the following command:
jamf-pro database restore /path/to/my-backup-file.sql.gz

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

Viewing Scheduled Backups

To see a list of scheduled backups and their frequencies, execute the following command:
jamf-pro database schedules list