1. Home
  2. Docs
  3. Backup Ninja
  4. Agent
  5. Command Line

Command Line

Backup Ninja agent, also known as a bartender, is an application that runs as a service on a database host and as a command-line interface to Backup Ninja API servers.

Configuration File

The command-line interface will look for the default configuration file at /etc/bartender.yaml. This path can be customized with -c or --config flag. As you can tell by looking at the file extension name, the configuration lines follow the YAML structure and it is automatically generated by a periodic pull from Backup Ninja API servers.

Command-Line Options

To get the list of supported command-line arguments and flags, simply run the command with --help flag:

$ bartender --help
bartender

  Usage:
    bartender [install|uninstall|deleteservice|upgrade|restart|decrypt|get-file]

  Subcommands:
    install (i) - Initialize the agent on the first installation and set it up as a service
    uninstall (u) - Uninstall the agent service & package
    deleteservice - Delete the agent service
    upgrade (p) - Upgrade the agent to the latest version
    restart (r) - Restart the agent service
    decrypt (d) - Decrypt encrypted backup
    get-file (g) - Download/Decrypt/Decompress/Copy a backup file

  Flags:
       --version  Displays the program version string.
    -h --help  Displays help with available flag, subcommand, and positional value parameters.
    -c --config  Path to the configuration file. "/etc/bartender.yaml" by default. (default: /etc/bartender.yaml)
    -d --db  Database connection string, eg.
    mysql://user:[email protected]:3306
    postgres://user:[email protected]
    mysql:/var/run/mysqld/mysqld.sock

Looking at the output above, there are a number of subcommands and global flags available. For every subcommand, you can get further details on the available options and arguments positioning by appending help, for example:

$ bartender decrypt help

Global Flags

The following table explains the global flags available for bartender:

Flag, shorthand Decription
--help, -h Displays help with the available flags, subcommands and positional value parameters.
--version Displays the program version string.
--config, -c Path to the configuration file. Default is /etc/bartender.yaml.
--db, -d The database connection string to perform a backup.

Subcommand Usage and Examples

install (i)

Initialize the agent on the first installation and set it up as a service. The shorthand for this subcommand is I and it does not accept any argument.

Example:

$ bartender install

uninstall (u)

Uninstall the agent service and package on the database node. The shorthand for this subcommand is u and it does not accept any argument.

Example:

$ bartender uninstall

delete service

Delete the agent service on the database node. It neither does have shorthand nor accept any argument.

Example:

$ bartender deleteservice

upgrade (p)

Upgrade the agent to the latest version. The upgrade procedure will include an automatic agent restart. The shorthand for this subcommand is p and it does not accept any argument.

Example:

$ bartender upgrade

restart (r)

Restart the agent service. This command is similar to the OS system restart, for example systemctl restart bartender. The shorthand for this subcommand is r and it does not accept any argument.

Example:

$ bartender restart

decrypt (d)

Decrypts encrypted backup file using a schedule name or encryption key. The shorthand for this subcommand is u and it accepts the following flags:

Flag, shorthand Description
--schedule, -s Schedule name that was used for backup creation.
--file, -f Path to the backup file.
--key, -k Encryption key when you first configured the backup schedule.
--output, -o Output, stdout by default.
--extract, -x Decompress the file. Use this flag if compression is enabled for this backup. Does not accept any argument.

Example:

$ bartender decrypt -k 14ca46fc2d501eac6381034e8158c19dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -f /storage/backups/backup.tar.gz -x -o my_backup_decrypted.tar

get-file (g)

Download/Decrypt/Decompress/Copy a backup file. This option is mainly built to download backup from cloud storage (if enabled) onto the backup host, for restoration or copying purposes. Using get-file a local storage backup will decrypt and decompress if required. The shorthand for this subcommand is g and it accepts the following flags:

Flag, shorthand Description
--file, -f File ID to download, decrypt and decompress. Go to Backup List and get the backup ID by clicking the Download icon. A command with a backup ID will be generated there.
--output, -o Output, stdout by default.

Example:

$ bartender get-file -f bsil9dkbhbisfb90hrag -o mysqldump_all_2019-10-15_051000_.sql
Was this article helpful to you? Yes No

How can we help?