SqlBak on Linux Reference Manual

The SqlBak application connects your computer to sqlbak.com and allows you to manage database backups from the web. In this post, you will see what commands and parameters it supports on Linux.

There are full and short forms of each command. The full form looks like:

sqlbak –<command> –<parameter1>=<value1> –<parameter2>=<value2> …


Example:

 sqlbak --test-connection --connection-id=20878

The short form is like:

sqlbak -<c> -<p1> <value1> -<p2> <value2>


Example:

 sqlbak -tc -ci 20878

Note also that you need to run any command under a user with root rights.

Get the help

sqlbak –help [–command=<command_name>] sqlbak -h [-c <command_name>]

This command outputs the complete list of supported commands with short descriptions.

To get help for a specific command add the –command (-c) parameter with the name of the command, for example:

sqlbak –help –command=update-settings


sqlbak -h -c us

Get app’s version

sqlbak –version sqlbak -v

Get the current status

sqlbak –info sqlbak -i

This command outputs the server’s name, sqlbak.com account it’s connected to and other useful information. For example, you may see something like

Server name: sqlbak_server
SqlBak.com account: SqlBakAccount
Status: the computer is registered SqlBak.com service
Logging: the app logging is activated

Register the server in sqlbak.com

sqlbak –register –key=<secret_key> [–name=<server_name>] [–mysqldump-path=<path>] [–mysql-path=<path>] [–pgdump-path=<path>] [–psql-path=<path>] [–sqlcmd-path=<path>] [–mssql-data=<path>]


sqlbak -r -k <secret_key> [-n <server_name>] [-md <path>] [-ms <path>] [-pd <path>] [-ps <path>] [-sq <path>] [-sqd <path>]

This command registers your computer as a server in sqlbak.com. After that, you will see it on the dashboard and will be able to run backup and maintenance jobs on your machine.

The only required parameter here is –key (-k). It receives your secret key that you can find on the download page when you’re logged in to sqlbak.com.

Example:

sqlbak –register –key=b9acdefc-9c57-4114-9772-9ba058c55196 –name=my_server


sqlbak -r -k b9acdefc-9c57-4114-9772-9ba058c55196 -n my_server

The optional parameters are:

  • –name (-n) specifies the name of the server that will be displayed on sqlbak.com (if omitted the hostname is used)
  • –mysql-path (-ms) sets path to MySQL (default is /usr/bin/mysql)
  • –mysqldump-path (-md) sets path to mysqldump utility (default is /usr/bin/mysqldump)
  • –psql-path (-ps) sets path to PostgreSQL (default is /usr/bin/psql)
  • –pgdump-path (-pd) sets path to pg_dump utility (default is /usr/bin/pg_dump)
  • –sqlcmd-path (-sq) sets path to sqlcmd utility (default is /opt/mssql-tools/bin/sqlcmd)
  • –mssql-data (-sqd) sets path to path to MS SQL data directory (default is /var/opt/mssql/data/)

Update server’s settings

sqlbak –update-settings [–name=<server_name>] [–mysqldump-path=<path>] [–mysql-path=<path>] [–pgdump-path=<path>] [–psql-path=<path>] [–sqlcmd-path=<path>] [–mssql-data=<path>]


sqlbak -us [-n <server_name>] [-md <path>] [-ms <path>] [-pd <path>] [-ps <path>] [-sq <path>] [-sqd <path>]

With this command you can change server’s name along with paths to DBMS and utilities mentioned in previous section.

Example:

sqlbak –update-settings –name=my_server –mysqldump-path=/usr/local/bin/mysqldump –pgdump-path=/usr/local/bin/pg_dump


sqlbak -us -n my_server -md /usr/local/bin/mysqldump -pd /usr/local/bin/pg_dump

Unregister the server from sqlbak.com

sqlbak –unregister sqlbak -u

This command removes the connection between the computer and sqlbak.com. After the connection is removed you will no longer see this computer on the dashboard and in the list of available servers on sqlbak.com.

Connect to DBMS

sqlbak –add-connection –db-type=mysql|postgresql|mssql –user=<user_name> [–password=<password>]   [–connection-type=<type>]   [–host=<host>] [–port=<port>] [–use-ssh=Y|N] [–ssh-host=<host>]


[–ssh-user=<user>] [–ssh-password=<password>] [–ssh-port=<port>] [–ssh-local-mapped-port=<port>] sqlbak -ac -dt mysql|postgresql|mssql -u <user_name> [-p <password>] [-ct <type>] [-h <host>] [-P <port>] [-ssh Y|N] [-sshh <host>] [-sshu <user>] [-sshup <password>] [-sshp <port>] [-sshmp <port>]

In order to backup databases, you need to establish connection between sqlbak application and one or more DBMS and this is what this command for.

When adding a connection, SqlBak will immediately try to connect and test it. If this fails the connection will not be added.

There are two required parameters:

  • –db-type (-dt) specifies the type of database you add connection to it should be one of the following values: mysql, postgresql or mssql
  • –user (-u) specifies a user name for DMBS connection

For example:

sqlbak –add-connection –db-type=mysql –user=admin –password=my_password


sqlbak -ac -dt mysql -u admin -p my_password

The optional parameters are:

  • –connection-type (-ct) specifies a connection type, at the moment the only supported value is tcp/ip
  • –host (-h) specifies a host address where DBMS is installed (default is localhost)
  • –password (-p) allows you to specify user’s password right in the command line (which is not secure enough); if you omit this parameter the password will be asked interactively
  • –port (-P) specifies a port for DBMS connection, the default values are: MySQL = 3306, PostgreSQL = 5432, MS SQL = 1433
  • –use-ssh (-ssh) allows you to establish DBMS connection through an ssh tunnel, can be either Y or N, default is N

If you’re using ssh tunnel then you need to specify some additional parameters:

  • –ssh-host (-sshh) specifies the remote host for ssh session
  • –ssh-port (-sshp) specifies the port to connect to the host (optional, default is 22)
  • –ssh-user (-sshu) specifies ssh user name
  • –ssh-password (-sshup) specifies ssh user password
  • –ssh-local-mapped-port (-sshmp) specifies the local mapped port for ssh tunnel (optional, default is 3306)

Get existing DBMS connections

sqlbak –show-connection


sqlbak -sc

This command outputs all DBMS connections in the following format:

Connection-Id: 1, DBMS-Type: mssql, Connection-Name: localhost:1433


Connection-Id: 2, DBMS-Type: mysql, Connection-Name: localhost:3306

Get current DBMS connection settings

sqlbak –show-connection –connection-id=<connection_id>


sqlbak -sc -ci <connection_id>

This command requires a connection identifier that you can get from the list of existing connections (see the previous section). As a result, you will see something like:

Connection-Id: 2, DBMS-Type: mysql, Connection-Name: localhost:3306, Host: localhost, Port: 3306, User: root, Use-SSH: 0, SSH-Host: None, SSH-Port: 22, SSH-Local-Mapped-Port: 3306, SSH-User: None

Update DBMS connection

sqlbak –update-connection –connection-id=<id> [–db-type=mysql|postgresql|mssql] [–user=<user_name>] [–password=<password>]   [–connection-type=<type>]   [–host=<host>] [–port=<port>] [–use-ssh=Y|N] [–ssh-host=<host>]


[–ssh-user=<user>] [–ssh-password=<password>] [–ssh-port=<port>] [–ssh-local-mapped-port=<port>] sqlbak -uc -ci <id> [-dt mysql|postgresql|mssql] [-u <user_name>] [-p <password>] [-ct <type>] [-h <host>] [-P <port>] [-ssh Y|N] [-sshh <host>] [-sshu <user>] [-sshup <password>] [-sshp <port>] [-sshmp <port>]

This command allows to change settings of an existing DBMS connection. It requires only one parameter: –connection-id (-ci). You can retrieve this identifier from the list of existing connections (see Get existing DBMS connections section).

Other parameters are optional and described in Connect to DBMS section.

Test DBMS connection

sqlbak –test-connection –connection-id=<id>


sqlbak -tc -ci <id>

This command checks whether the sqlbak app is able to connect to DBMS using the current connection settings. If everything is fine you should see:

Connection-Id: 2, DBMS-Type: mysql, Connection-Name: localhost:3306


The connection is tested successfully.

Remove DBMS connection

sqlbak –remove-connection –connection-id=<id>


sqlbak -rc -ci <id>

This command removes a DBMS connection.

Get job list

sqlbak –jobs


sqlbak -j

This command shows information of all jobs configured for this server on sqlbak.com. The output will be like this:

Job-Id: 23668, Job-Name: New Backup job, Connection-Id: 1, DBMS-Type: mysql, Connection-Name: localhost:3306

Run a job

sqlbak –run-job –job-id=<job_id>


sqlbak -rj -ji <job_id>

This command allows you to immediately start job execution. The only thing you need to know is a job identifier that you can get from the job list (see the previous section). While the job is running you will see the detailed log on the console.

Set logging ON and OFF

sqlbak –set-logs –activate=Y|N


sqlbak -sl -a Y|N

This command activates or deactivates sqlbak app logging. These logs can be sent to the support team for the support case investigation. The logging is activated by default.

Upload logs to the support team

sqlbak –upload-logs


sqlbak -ul

This command uploads sqlbak logs to the support team for the future support case investigation

When the logs are uploaded you should see the following message:

The logs have been successfully uploaded.

7 thoughts on “SqlBak on Linux Reference Manual

  1. ubuntu@ubuntu-B250M-D2V:/etc/mysql/mysql.conf.d$ curl -sSL https://sqlbak.com/download/linux/latest | sudo bash -s 606f965d-7bcb-4b79-84a8-853e21c4be6d
    bash: line 1: #!/bin/bash: No such file or directory
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    apt-transport-https is already the newest version (1.2.32ubuntu0.2).
    gnupg2 is already the newest version (2.1.11-6ubuntu2.1).
    The following package was automatically installed and is no longer required:
    snapd-login-service
    Use ‘sudo apt autoremove’ to remove it.
    0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.

    Get a public gpg.key

    OK

    Add a link to SqlBak app’s package to the repository list

    Update the package repository list

    Hit:1 http://linux.teamviewer.com/deb stable InRelease
    Hit:2 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial InRelease
    Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
    Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InRelease
    Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
    Get:6 https://sqlbak.com/deb/1/1/50 stable InRelease [1,639 B]
    Hit:7 http://dl.google.com/linux/chrome/deb stable InRelease
    Get:8 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
    Fetched 327 kB in 1s (174 kB/s)
    Reading package lists… Done

    Install the app

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    sqlbak is already the newest version (1.1.50).
    The following package was automatically installed and is no longer required:
    snapd-login-service
    Use ‘sudo apt autoremove’ to remove it.
    0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.

    Register the application on sqlbak.com …

    Handling a console command has failed. Failed to register this server. “Failed to register this server. “Failed to make a request to remote server. PSB:0002 Failed to register a new server. Please try again or contact the service provider.
    PSB:0006 Failed to register server “ubuntu-B250M-D2V”. The server with the same name is already connected. Please change the name and connect again.”. “. .
    ubuntu@ubuntu-B250M-D2V:/etc/mysql/mysql.conf.d$

    1. Hello,

      It seems you run the following command twice:

      curl -sSL https://sqlbak.com/download/linux/latest | sudo bash -s 606f965d-7bcb-4b79-84a8-853e21c4be6d

      There is no need to run the command again, you have already installed the application and registered it on sqlbak.com

      You can check all the connected servers at your “Dashboard” https://sqlbak.com/dashboard/ page.

      If for some reason your server is offline, please restart the service:

      sudo service sqlbak restart

  2. Is it possible to run sqlbak without registering? My VM and SQL servers are in an internal network with no access to the internet.

    Thank you

  3. Hi,

    I have a MariaDB server in a VM which is only accessible from localhost, which means I have to connect through a SSH tunnel to connect from the outside. So far, so good – problem is that I’ve setup the SSH server to only authorize connections by certificate. That doesn’t seem possible from sqlbak?

  4. Hello,
    I have successfully setup SqlBak on my CentOS 7 server. It can connect to a remote mssql server and I was able to create a job through https://sqlbak.com/dashboard. However, when I run the job I get the following error message:
    ERROR Job execution error: Failed to backup a DBMS – “TDPA-Prod-SQL-V1” . “Msg 40510, Level 16, State 1, Server tdapsqlsvr, Line 1 Statement ‘BACKUP DATABASE’ is not supported in this version of SQL Server. “.
    Any idea how I can get around this error?

    Thank you
    Felipe

Leave a Reply

Your email address will not be published. Required fields are marked *