Skip to content

Automatically Save a Database ​

Cron can be used to execute bash scripts at specified intervals. The easiest way is to create a bash file that saves the database and place it in a default cron directory.

Cron default directories:

/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly

Bash Script to Save the Current Database ​

To save databases automatically, a bash script (e.g. taurec_save_database) can be created and placed in a standard cron folder (e.g. /etc/cron.daily).

The bash script can be made executable with the chmod command:

shell
chmod +x /etc/cron.daily/taurec_save_database

The bash script should start the console application with parameters.

Example of a bash script:

#!/bin/bash
/home/taurec/application/console \
    Batch=True \
    User=Local_SaveDatabase \
    Password=sG7t&z$3i2#18b1 \
    Database=Finance \
    Host=127.0.0.1 \
    Port=8700 \
	Timeout=True \
    Timeout=300 \
    File=/home/taurec/application/command/save_database.txt \
    IgnoreErrors=False

Console Parameters ​

First Parameter ​

Path to the console application (e.g. /home/taurec/application/console).

Batch ​

Must be True for bash scripts.

User ​

Name of the user. It is recommended to use a Local user. A Local user must be created manually and the name should start with Local, e.g. Local_Import or Local_Save. In the database, the user kind must be Admin to save databases. A Local user can only connect directly on the server (localhost), not from the network. Therefore it is considered secure to write the password in the bash file in this case.

Password ​

Password of the user.

Database ​

Name of the database to be saved.

Host ​

Name or IP address of the server.

Port ​

Port of the server. The default port is 8700.

TLS ​

If the server uses TLS (Transport Layer Security) this parameter must be True.

Timeout ​

Timeout in seconds. The default timeout is 300 seconds.

File ​

Path to the command file (e.g. /home/taurec/application/command/save_database.txt). The command file is a text file with one or more API commands in text format. In this example, the SAVE DATABASE API command saves the current database. SAVE DATABASES saves all running databases, regardless to which database the user that issues the command is connected.

Example of a command file to save a database (e.g. save_database.txt):

SAVE DATABASE

IgnoreErrors ​

If a file contains several commands and one command returns an error, execution is stopped. If IgnoreErrors=True, the following commands will still be executed. The default value is False.