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 this:

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 the server’s name along with paths to DBMS and utilities mentioned in the 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 a connection between the 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 a connection to it should be one of the following values: MySQL, PostgreSQL, MS SQL, Azure, or Mongo
  • –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 changing the 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.

34 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$

    Reply
  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

    Reply
  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?

    Reply
  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

    Reply
  5. I’m trying to configure the FTP destination.

    When i click test to check it, after 10 seconds the dashboard display the following error:
    Failed to test the destination. “‘>’ not supported between instances of ‘str’ and ‘int'”.

    I check my connection parameters, credentials, everything but i can’t to add this destination.

    Why?

    Thanks a lot.

    Reply
  6. Hi I am getting this postgresql backup via sqlbal on centos 7.
    Following is error:
    Handling a console command has failed. Failed to add DBMS connection. “table Connection has no column named Database”. .

    Reply
  7. Tried running a test back and log returned below:

    Job execution error: mysqldump: [Warning] Using a password on the command line interface can be insecure.
    mysqldump: Error: ‘Access denied; you need (at least one of) the PROCESS privilege(s) for this operation’ when trying to dump tablespaces
    mysqldump: Got error: 1227: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation when doing refresh

    Reply
  8. Hi,
    This doesn’t seem to work with RaspberryPi anymore:

    user@raspberrypi:~ $ sudo apt-get update
    Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
    Hit:2 http://archive.raspberrypi.org/debian buster InRelease
    Get:3 https://sqlbak.com/raspberry_deb/1/2/11 stable InRelease [1,619 B]
    Get:4 https://sqlbak.com/raspberry_deb stable InRelease [1,619 B]
    Fetched 3,238 B in 2s (1,685 B/s)
    Reading package lists… Done
    N: Skipping acquire of configured file ‘main/binary-armhf/Packages’ as repository ‘https://sqlbak.com/raspberry_deb/1/2/11 stable InRelease’ doesn’t support architecture ‘armhf’
    N: Skipping acquire of configured file ‘main/binary-armhf/Packages’ as repository ‘https://sqlbak.com/raspberry_deb stable InRelease’ doesn’t support architecture ‘armhf’

    Kind Regards,
    Chris

    Reply
  9. Hi
    When sudo apt update I get:
    E: The repository ‘https://sqlbak.com/deb stable Release’ no longer has a Release file.
    N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.

    Reply
  10. Hello
    Been having the error
    execution error: /usr/pgsql-13/bin/pg_dump: unrecognized option ‘–oids’

    any help on how to bypass it

    Reply
    • Hi pregtech,

      To resolve the issue, please go to your backup job’s settings page, scroll down to the “Job Options” section, click on the “More Settings…” link and disable the “Dump object identifiers” option.

      If you have any other questions, please let us know.

      Thank you!

      Reply
  11. We have a server with two scheduled jobs, a db backup job and a maintenance one, db connection tested successfully, and we can run the jobs from the dashboard and they are working, but they are not working by themselves according the the schedule configurations.

    Reply
  12. I am unclear about a few things
    -is there a way to encrypt backups before sending to your service?
    -can I backup MariaDB as a drop in replacement for MySQL?
    -can I do point in time restore operations?

    Reply
    • Hi Dean,

      > Is there a way to encrypt backups before sending to your service?

      Sorry, but there is no easy way to do this. For SQL Server, you can use TDE, but there is no way to do it for MySQL and PostgreSQL. With SqlBak you can set the encrypt option (enable the “Encrypt compressed files” option) to encrypt the backups before sending them to destinations. Note that the backups are not stored on the SqlBak side, they are sent to your destinations.

      > Can I backup MariaDB as a drop in replacement for MySQL?
      Yes, you can do it.

      > Can I do point in time restore operations?

      You can try to perform incremental backups every 15 minutes and then restore them. Note, the process to restore incremental; backups may take longer time due to the chain of incremental backups. To resolve the issue, please performer full backups from time to time.

      Reply
  13. Hi sqlbak,

    I have a little problem connecting to mysql host, here’s the case:

    I have a debian server and installed docker in it, there are 2 containers installed mysql container and sqlbak container, both of which connect using the same network that is “Internal” And can communicate with each other

    In the mysql container I just typed the command ‘mysql’ and the output results I directly logged into the mysql server without typing username and password

    In the sqlbak container everything is installed perfectly and registered in the sqlbak dashboard, the problem is when I create a new DBMS they ask for username and password to add it, Meanwhile in the mysql container I didn’t type the username and password. What should I input in the DBMS if I want to add mysql without username and password?

    Thank you,
    Best regards

    Reply
  14. My docker app has Postgres 15.1 and reading the error below seems to me a mismatch of version.
    Could you update the docker app with last version compatible of pg_dump?

    Thanks Alen

    Job execution error: pg_dump: error: server version: 15.1 (Debian 15.1-1.pgdg110+1); pg_dump version: 14.5 (Ubuntu 14.5-1.pgdg18.04+1)
    pg_dump: error: aborting because of server version mismatch

    Reply
  15. I tried to update setting… but I GOT an error:

    “‘ascii’ codec can’t encode character ‘с’ in position 9: ordinal not in range(128)”

    From my consolle in my docker app:
    sqlbak –update-settings –pgdump-path=/usr/lib/postgresql/15/bin/pg_dump –psql-path=/usr/lib/postgresql/15/bin/psql

    Reply

Leave a Comment