C.3. Database Commands

The savapage-db command-line tool provides functions for manipulating the database. The tool is located in /opt/savapage/server/bin/[platform]/ and needs to be executed from a command prompt. The syntax of the command is:

usage: [OPTION]
    --db-config-get <NAME>         Gets configuration property value. This is an
                                   advanced option. Please contact SavaPage Support
                                   before use.
    --db-config-set <NAME=VALUE>   Sets configuration property value. This is an
                                   advanced option. Please contact SavaPage Support
                                   before use.
    --db-delete-logs <DAYS>        Deletes application, account transaction and
                                   document log data older than DAYS. A DAYS value of
                                   zero (0) will remove all log data from the system.
    --db-export                    Exports the database to the default backup
                                   location.
    --db-export-to <FILE|DIR>      Exports the database to the specified file or
                                   directory.
    --db-import <FILE>             Imports the database from the specified file.
                                   Deletes any existing data before loading the data.
    --db-init                      Re-initializes the database even if it already
                                   exists.
    --db-run-script <FILE>         Runs SQL statements from the specified script
                                   file. NOTE: Only perform as requested by SavaPage
                                   Support.
    --db-run-sql <STATEMENT>       Runs an SQL statement. NOTE: Only perform as
                                   requested by SavaPage Support.
 -h,--help                         Displays this help text.

The command must be run as the savapage user. An example:

sudo su - savapage
cd server/bin/linux-x64
./savapage-db --db-import /home/john/savapage-backup.zip

savapage-db needs exclusive access to the database. It is important that any SavaPage services and processes are stopped before executing a command. Failure to do so will result in a "database in use" error message. The savapage-db command is a powerful low-level utility and its use on a production system should be carefully considered. Details of the available commands are discussed below.

C.3.1. db-config-get

With this option the (decrypted) value of a Configuration Property can be retrieved. Also see Section C.1.8, “getConfigProperty”.

C.3.2. db-config-set

With this option the value of a Configuration Property can be set (and encrypted). Also see Section C.1.18, “setConfigProperty”.

C.3.3. db-delete-logs

This option delete old log data from the system. This command will permanently delete the following data.

  • Document logs - Record all document history and statistics

  • Transaction logs - Record all financial history and statistics

  • Application logs - Record application status and error messages

The DAYS option determines what data will be deleted. If DAYS is 90, then all log data more than 90 days old will be deleted. A value of zero (0) will remove all historical log data from the system. This is an example:

savapage-db --db-delete-logs 90

C.3.4. db-export and db-export-to

This option exports the data from the database. The application server must be stopped before performing the export. See Section C.4, “Stopping and Starting the Server”.

Tip

If you want to perform an online backup without stopping the application server you can use the backup function in the Admin Web App.

savapage-db --db-export   1 
savapage-db --db-export-to /home/john    2
savapage-db --db-export-to /home/john/savapage-backup.zip   3

1

The database export file is created in the /opt/savapage/server/data/backups directory and the file is named savapage-export-[date-time].zip.

2

This option is used to override the default backup directory. The filename will still be named savapage-export-[date-time].zip.

3

The full path and filename where the backup is saved is specified.

Note

When executing the command the last line echoed to stdout is the canonical path of the database export file.

Caution

If the directory or filename parameters contain spaces, then the argument needs to be quoted.

C.3.5. db-import

This option imports the data (from a previous export) into the database. The application server must be stopped to perform the import. This is an example:

savapage-db --db-import /home/john/savapage-backup.zip

Note

Progress and statistics of the import process are written to stdout.

Warning

Be careful, existing data in the database are erased.

C.3.6. db-init

This option initializes a database, creating the required tables and initial data. The application server must be stopped before you initialize the database. This is the command:

savapage-db --db-init

Warning

Be careful, existing data in the database are erased.